Poetry
Poetry…
공식 문서
https://python-poetry.org/docs/#installation
추천 설치 방법
Python 설치
먼저 Python의 설치여부와 버전을 확인한다.
snoopy_kr@iMac ~ % python --version
Python 3.12.4
Poetry 설치
Poetry를 맥에서 설치하는 방법
snoopy_kr@iMac ~ % curl -sSL https://install.python-poetry.org | python3.12 -
Retrieving Poetry metadata
# Welcome to Poetry!
This will download and install the latest version of Poetry,
a dependency and package manager for Python.
It will add the `poetry` command to Poetry's bin directory, located at:
/Users/snoopy_kr/.local/bin
You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.
Installing Poetry (1.8.3): Done
Poetry (1.8.3) is installed now. Great!
To get started you need Poetry's bin directory (/Users/snoopy_kr/.local/bin) in your `PATH`
environment variable.
Add `export PATH="/Users/snoopy_kr/.local/bin:$PATH"` to your shell configuration file.
Alternatively, you can call Poetry explicitly with `/Users/snoopy_kr/.local/bin/poetry`.
You can test that everything is set up by executing:
`poetry --version`
설치할 디렉토리 지정 (권한 문제해결을 위해 sudo사용)
설치 위치 : /usr/local/poetry/bin/poetry
snoopy_kr@Lees-MacBook-Pro ~ % curl -sSL https://install.python-poetry.org | sudo POETRY_HOME=/usr/local/poetry python3.12 -
snoopy_kr@Lees-MacBook-Pro ~ % /usr/local/poetry/bin/poetry --version
Poetry (version 2.0.1)
설치할 디렉토리 지정해서 설치한 경우 삭제
snoopy_kr@Lees-MacBook-Pro ~ % curl -sSL https://install.python-poetry.org | sudo POETRY_HOME=/usr/local/poetry python3.12 - --uninstall
일반적인 삭제
snoopy_kr@Lees-MacBook-Pro ~ % curl -sSL https://install.python-poetry.org | python3.12 - --uninstall
에러 대처법
에러 발생
snoopy_kr@iMac ~ % curl -sSL https://install.python-poetry.org | python3.12 -
Traceback (most recent call last):
File "/Users/Shark/Library/Caches/pypoetry/virtualenvs/ocr-api-D_-VbPbb-py3.11/lib/python3.11/site-packages/albumentations/check_version.py", line 29, in fetch_version_info
with opener.open(url, timeout=2) as response:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 519, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 1391, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)>
[처리 방법]
파인더에서 Applications(응용프로그램) > Python3.xx 폴더 > Install Certificates.command 파일 실행
[참조] https://github.com/python-poetry/install.python-poetry.org/issues/52
poetry 환경 설정 (.zshrc)
- POETRY : PATH 지정
- POETRY_CACHE_DIR : poetry가 사용할 cache 디렉토리로 설치된 package와 env설정이 저장
snoopy_kr@iMac ~ % cat .zshrc
export GOROOT=/usr/local/go
export GOPATH=$HOME/Apps/go
export ANACONDA=$HOME/Apps/anaconda3
export FLUTTER=$HOME/Apps/flutter
export PROTOC=$HOME/Apps/protoc
export POETRY=/usr/local/poetry
export POETRY_CACHE_DIR=$HOME/Working/Poetry
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:$ANACONDA/bin:$POETRY/bin:$FLUTTER/bin:$PROTOC/bin
snoopy_kr@iMac ~ % poetry --version
Poetry (version 1.8.3)
package 전체가 아민 일부 모듈만 설치
‘import matplotlib.pyplot as plt’ 같이 모듈 단위 설치가 필요한 경우
(multimodalexam-py3.11) snoopy_kr@iMac MultiModalExam % poetry add "matplotlib[pyplot]"
git를 통한 package 설치 (pyproject.toml)
numpy = ">=1,<2"
torch = "2.2.2"
torchaudio = "2.2.2"
torchvision = "0.17.2"
matplotlib = {extras = ["pyplot"], version = "^3.9.1"}
openai-whisper = { git = "https://github.com/openai/whisper.git", rev = "v20231117" }
[[tool.poetry.source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cpu"
priority = "explicit"
댓글남기기