install
https://python-poetry.org/docs/#installing-with-the-official-installer
for Windows
# for Powershell / Windows
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
# add PATH, poetry 명령어 사용을 위해 별도로 추가해줘야 함
# poetry file만 1개 %APPDATA%\Python\Scripts 위치에 설치되기 때문에 별도로 경로 추가필수*
# 시스템 환경변수에서 아래 경로를 추가하던가
# %APPDATA%\Python\Scripts를 아래 명령어를 통해서 추가해야 함
_________________
# 윈도우 Path설정 - powershell에서 아래 명령어로 추가하던가
[System.Environment]::SetEnvironmentVariable('path', $env:APPDATA + "\Python\Scripts\;" + [System.Environment]::GetEnvironmentVariable('path', "User"),"User")
# env reloading without Terminal Kill
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
for WSL, linux
# for linux, macOS, WSL
curl -sSL https://install.python-poetry.org | python3 -
# Add PATH in WSL
echo '[[ -d $HOME/.local/bin ]] && export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
# apply)
source ~/.bashrc
usage
___________________
# for init or apply
poetry new OOO
or
poetry init
poetry config virtualenvs.in-project true
______________
# activate for venv environment
poetry shell
poetry show
______________
# add package , 1개씩 필요한 것 설치
poetry add pandas
poetry add "pandas>=2.1.2"
# add all package, ,설정해둔 package 한번에 설치
poetry install
# Installing dependencies only
poetry install --no-root
# remove package , 미사용 패키지 삭제
poetry remove pandas
# update installed package, 오래된 package versions 최신으로 업데이트
poetry self update
_________
# run temporary
poetry run python main.py
poetry run pip install numpy
_____________________
# 설정하는 방법들
# Allow >=2.0.5, <3.0.0 versions
poetry add pandas@^2.0.5
# Allow >=2.0.5, <2.1.0 versions
poetry add pandas@~2.0.5
# Allow >=2.0.5 versions, without upper bound
poetry add "pandas>=2.0.5"
# Allow only 2.0.5 version
poetry add pandas==2.0.5
_
poetry env list
# pyenv에서 현재 설정한 python versions으로 venv 생성
poetry env use python
https://python-poetry.org/docs/basic-usage/
Basic usage | Documentation | Poetry - Python dependency management and packaging made easy
Why a nested shell? Child processes inherit their environment from their parents, but do not share them. As such, any modifications made by a child process is not persisted after the child process exits. A Python application (Poetry), being a child process
python-poetry.org
_
반응형