python:: install poetry // howTo use poetry 사용법

 

 

 

 

install

 

# https://python-poetry.org/docs/#installing-with-the-official-installer

# for Powershell / Windows
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
 
 
# add PATH, poetry 명령어 사용을 위해 별도로 추가해줘야 함
# 시스템 환경변수에서 아래 2개 경로를 추가하던가
%APPDATA%\Python\Scripts
%APPDATA%\pypoetry\venv

# powershell에서 아래 명령어로 추가하던가
[System.Environment]::SetEnvironmentVariable('path', $env:APPDATA + "\Python\Scripts\;"  + [System.Environment]::GetEnvironmentVariable('path', "User"),"User")
[System.Environment]::SetEnvironmentVariable('path', $env:APPDATA + "\pypoetry\venv\Scripts\;"  + [System.Environment]::GetEnvironmentVariable('path', "User"),"User")
 
 
_________________________________
# 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 


_________________________________
# update library version
# for linux , error in windows maybe
poetry self update


_

 

 

 

 

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
poetry add pandas
poetry add "pandas>=2.1.2"

poetry install

# Installing dependencies only
poetry install --no-root

# remove package
poetry remove pandas


# 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

_

 

 

 

 
 
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

 
 

 

$env:PATH = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)


 

 

 

 

 


_

반응형