Python Package Management via Poetry
Python Packaging & Dependency Management
- Python Poetry
On macOS & Ubuntu
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
# This is the recommended way to install Poetry to ensure it is isolated from the rest of your system by vendorizing its dependencies.
Add this to your .bash_profile
/ .bashrc
/ .zshrc
/ etc after the pyenv
config you added above:
export PATH="$HOME/.poetry/bin:$PATH”
The bottom of your *rc file should now look like this (including pyenv config steps from above)
export PYENV_VIRTUALENV_DISABLE_PROMPT=0
export PATH="$HOME/.poetry/bin:$PATH"
if [[ -z "$VIRTUAL_ENV" ]]; then
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
export PATH="$HOME/.poetry/bin:$PATH”
Source your shell profile or start a new session:
source ~/<rc_file_name>
Verify that Poetry installed correctly:
poetry --version
Install dependencies
poetry install
Important: Poetry should now be your exclusive package manager. That means when you need to add or remove packages to a repository, you use poetry add <package> [--dev]
, poetry update [<package>] [--dev]
and poetry remove <package> [--dev]
in a feature branch and commit the resulting changes to the pyproject.toml
and poetry.lock
files (as opposed to using pip
directly).