728x90
반응형

1. node.js와 npm 설치가 먼저 선행되어야 함.

먼저, 저장소를 업데이트합니다.

sudo apt update

그 다음, Node.js를 설치합니다.

sudo apt install nodejs -y

 

이제, npm을 설치합니다.

sudo apt install npm -y

 

Node.js와 npm이 정상적으로 설치되었는지 확인합니다.

node --version
npm --version

Node Version Manager(nvm)를 사용하는 방법:
nvm을 사용하면 다양한 버전의 Node.js를 쉽게 설치하고 관리할 수 있습니다.

먼저 nvm을 설치하기 위한 스크립트를 다운로드하고 실행합니다.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

nvm을 설치한 후에, 새 터미널 창을 열거나 기존 터미널 창의 환경을 다시 로드합니다.

source ~/.bashrc

nvm을 사용하여 원하는 버전의 Node.js를 설치합니다. 예를 들어, 최신 LTS 버전을 설치하려면 다음 명령어를 사용합니다.

nvm install --lts

 

Node.js와 함께 설치된 npm이 있는지 확인합니다.

node --version
npm --version

이 중에서 가장 적합한 방법을 선택하여 Node.js와 npm을 설치하고 사용할 수 있습니다.

2. cmake가 설치 안되있다면 설치

sudo apt-get install cmake -y

cmake가 설치되었는지 확인하세요. 터미널에서 다음 명령어를 실행합니다:

cmake --version

설치가 성공적으로 완료되었다면, cmake 버전이 출력됩니다.

3. Boost 라이브러리 설치

우분투에서 Boost 라이브러리를 설치하려면, 아래와 같은 명령어를 터미널에서 실행하세요:

sudo apt-get update 
sudo apt-get install libboost-all-dev -y

4. 파이썬 perspective 라이브러리 설치

pip install perspective-python

5. 주피터랩에서 perspective 확장 설치

먼저 Extension 기능 Enable한 후 아래와 같이 검색하거나 명려어 입력으로 설치 

jupyter labextension install @finos/perspective-jupyterlab

 

Perspective 공식 홈페이지

https://perspective.finos.org/docs/python/

 

[참고] 오류 내용 

 

- 오류내용 : cmake가 필요하다는 내용

jovyan@aaa:~$ pip install perspective-python
Collecting perspective-python
  Downloading perspective-python-2.0.1.tar.gz (7.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.0/7.0 MB 10.8 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [15 lines of output]
      Traceback (most recent call last):
        File "/opt/conda/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/opt/conda/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/opt/conda/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-uj6b3_f8/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-uj6b3_f8/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-uj6b3_f8/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 45, in <module>
      Exception: Requires cmake
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

 

 

- 오류내용 : Boost 라이브러리가 필요하다는 내용 

CMake Error at /opt/homebrew/Cellar/cmake/3.26.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
        Could NOT find Boost (missing: Boost_INCLUDE_DIR)
      Call Stack (most recent call first):
        /opt/homebrew/Cellar/cmake/3.26.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
        /opt/homebrew/Cellar/cmake/3.26.3/share/cmake/Modules/FindBoost.cmake:2377 (find_package_handle_standard_args)
        CMakeLists.txt:276 (find_package)


      -- Configuring incomplete, errors occurred!
      Traceback (most recent call last):
        File "/Users/shinaelee/Compose/myvenv/myenv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 351, in <module>
          main()
        File "/Users/shinaelee/Compose/myvenv/myenv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 333, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/shinaelee/Compose/myvenv/myenv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 249, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/jupyter_packaging/build_api.py", line 23, in build_wheel
          val = orig_build_wheel(
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 416, in build_wheel
          return self._build_with_temp_dir(['bdist_wheel'], '.whl',
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 401, in _build_with_temp_dir
          self.run_setup()
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 291, in <module>
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1244, in run_command
          super().run_command(command)
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 343, in run
          self.run_command("build")
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1244, in run_command
          super().run_command(command)
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 131, in run
          self.run_command(cmd_name)
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1244, in run_command
          super().run_command(command)
        File "/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-build-env-epqyex5v/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "<string>", line 112, in run
        File "<string>", line 127, in run_cmake
        File "<string>", line 211, in build_extension_cmake
        File "/Users/shinaelee/anaconda3/lib/python3.10/subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/opt/homebrew/bin/cmake', '/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-install-671q9r0d/perspective-python_6132b12cc2814811b529c5e382b1b57b/dist', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-install-671q9r0d/perspective-python_6132b12cc2814811b529c5e382b1b57b/build/lib.macosx-10.9-x86_64-cpython-310/perspective/table', '-DCMAKE_BUILD_TYPE=Release', '-DPSP_CPP_BUILD=1', '-DPSP_WASM_BUILD=0', '-DPSP_PYTHON_BUILD=1', '-DPSP_PYTHON_VERSION=3.10', '-DPython_ADDITIONAL_VERSIONS=3.10', '-DPython_FIND_VERSION=3.10', '-DPython_EXECUTABLE=/Users/shinaelee/Compose/myvenv/myenv/bin/python', '-DPYTHON_LIBRARY=/Users/shinaelee/anaconda3/lib', '-DPYTHON_INCLUDE_DIR=/Users/shinaelee/anaconda3/include/python3.10', '-DPython_ROOT_DIR=/Users/shinaelee/Compose/myvenv/myenv', '-DPython_ROOT=/Users/shinaelee/Compose/myvenv/myenv', '-DPSP_CMAKE_MODULE_PATH=/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-install-671q9r0d/perspective-python_6132b12cc2814811b529c5e382b1b57b/dist/cmake', '-DPSP_CPP_SRC=/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-install-671q9r0d/perspective-python_6132b12cc2814811b529c5e382b1b57b/dist', '-DPSP_PYTHON_SRC=/private/var/folders/jp/j992by256v53v2qry6q5zd080000gn/T/pip-install-671q9r0d/perspective-python_6132b12cc2814811b529c5e382b1b57b/dist/../perspective', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for perspective-python
Failed to build perspective-python
ERROR: Could not build wheels for perspective-python, which is required to install pyproject.toml-based projects

 

 

반응형
728x90
반응형

엑셀 파일을 저장 시, 테이블 (표)가 포함되어 있는 경우, 저장 시 이와 같은 메세지가 뜨며 저장이 안된다 

We found a problem with some content in 'new_test.xlsx'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.

 

 

 

문제는 테이블 저장 시 `displayName` 에 있었다. 
아래와 같은 형식으로 displayName의 표이름을 저장해주면 위와 같은 에러는 발생하지 않는다. 

 

tab = Table(displayName="Tb", ref=tb_size)
또는
 
tab = Table(displayName="Tbl_1", ref=tb_size)

 

 

참고 : https://stackoverflow.com/questions/62300178/openpyxl-created-excel-file-with-table-causes-file-that-requires-recovery-error

반응형
 
 
 
반응형
728x90
반응형

pandas

pandas에서 read_csv 할 때 읽어오려는 파일이 테이블형식이 아니라, row에 다른 형태의 정보가 섞여있어
파싱에 오류가 있는 경우가 있음.
cp949 등 인코딩 문제라고 생각했으나, 테이블형식이 아닌 첫 3줄을 날리고 가져오니, 오류없이 읽어올 수 있었음

 

df = pd.read\_csv(working\_file, skiprows=3, sep=',')
 
반응형
728x90
반응형

headless 크롬 사용 중 한동안 아래 에러때문에 고생해서...기록해둠.  

"Message: session not created from timeout: Timed out receiving message from renderer: 600.000" 

아래 코드대로 실행했더니 마침내 동작. 

# 셀레니움 작동 테스트 
from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible=0, size=(1024, 768)) 
display.start()

user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)'

options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('user-agent={0}'.format(user_agent))
driver = webdriver.Chrome('/home/venus/Notes/98/chromedriver',options=options)
# 아무런 경고가 없다면 이상없이 작동되는 것입니다

driver.get(url='https://naver.com')
# 페이지 이동

print(driver.current_url)
# 이동되었는지 확인

driver.close()
# 종료

 

핵심은 아래 코드를 삽입해주면 되는 것이었다. 

 
from pyvirtualdisplay import Display
display = Display(visible=0, size=(1024, 768)) 
display.start()

 

반응형
728x90
반응형

오류 화면은 찍어두지 못했으나, 

맥북에서 chromedriver 를 다운받고 selenium 실행 시 이 설정이 없으면 에러가 발생한다. 

 

해결방법 

1. Terminal 실행 
2. chromedriver 파일이 저장된 경로로 이동.
3. 아래의 명령어를 입력.

xattr -d com.apple.quarantine chromedriver

 

이후 코드 재실행하면 잘 실행이 됩니다.

 

 
반응형
728x90
반응형

선생님께 추천받음.

아래 다운받을 수 있는 링크임.

 

http://byteofpython-korean.sourceforge.net/byte_of_python.pdf

 

반응형
728x90
반응형

 

import sys
import io
import urllib.request as req
from urllib.parse import urlparse

sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')

url = "http://www.encar.com"

mem = req.urlopen(url)

# print(type(mem))
# python dict {}  , list [], tuple()  예습 필요


# print ("geturl", mem.geturl())
# print("status", mem.status)  # 응답값 200, 404, 403, 500 등 알아두어야 함.
# print("headers",mem.getheaders())

# print("info",mem.info())
# print("code", mem.getcode())
# print("read", mem.read(50).decode("utf-8"))  #옛날 사이트로 되있다면 euc-kr 등으로 디코딩함.

print(urlparse(url))

 

import sys
import io
import urllib.request as req
from urllib.parse import urlencode

sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')

#구글 검색 my ip api
# https://www.ipify.org/ -- 출처


API = "https://api.ipify.org"

values = {
'format' : 'json'
}

print('before',values)
params = urlencode(values)
print('after',params)

url = API + "?" + params
print("요청 url", url)

reqData = req.urlopen(url).read().decode('utf-8')
print("출력",reqData)

 

 

숙제 

import sys
import io
import urllib.request as req
from urllib.parse import urlencode

sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')

#구글 검색 my ip api
# https://www.ipify.org/ -- 출처

imgUrl1 ="https://ssl.pstatic.net/tveta/libs/1242/1242071/7263bcd2e96061265636_20190705115802112.jpg"
adUrl2 = "https://ssl.pstatic.net/tveta/libs/1239/1239407/92a189eb83ec9dcf5684_20190503133602254.jpg"

savePath1 ="homework.jpg"
savePath2 ="homework2.jpg"

f1 = req.urlopen(imgUrl1).read()  #이미지를 읽어와 f 에 저장
f2 = req.urlopen(adUrl2).read()

# saveFile1 = open(savePath1, 'wb')  # w: write, r: read, a: add  b:binary
# saveFile2 = open(savePath2, 'wb')
# saveFile1.write(f1)  #saveFile에 f의 데이터를 씀
# saveFile1.close()  #항상 리소스를 반납해줘야 하는 것 잊지 말것

# 이 아래 with 문을 자주 쓰는게 더 좋다고 함.
# 파이썬 2.7버전 이후로만 지원되며 with 문을 벗어나면 자동으로 자원 반환함

with open(savePath1, 'wb') as saveFile1:
    saveFile1.write(f1)

with open(savePath2, 'wb') as saveFile2:
    saveFile2.write(f2)


print("다운로드 완료!")

 

 

 

 

반응형

+ Recent posts