Gangmax Blog

Python Poetry

Similar to “Pipenv“, “Poetry“ is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

Installation

1
2
# Before running make sure you have "Python" installed.
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -

After running the script, make sure you have the following content in your “~/.zshrc” file, if you’re using “zsh”:

1
export PATH="$HOME/.poetry/bin:$PATH"

Project setup

1
2
3
4
5
6
# For a new project:
poetry new poetry-demo

# For a pre-existing project:
cd pre-existing-project
poetry init

Running

1
2
3
4
# Start the virtual environeent:
poetry shell
# Run script directly:
poetry run python ./run.py

More details can be also found in this post.

Comments