DEV Community

Sabrina Pereira
Sabrina Pereira

Posted on

Getting started with Poetry

Installation & environment activation

Install Poetry (Linux/WSL. For others, see Poetry docs):

curl -sSL https://install.python-poetry.org | python3 -
Enter fullscreen mode Exit fullscreen mode

Create new project:

poetry new <project-name>
Enter fullscreen mode Exit fullscreen mode

Navigate to project directory:

cd <project-name>
Enter fullscreen mode Exit fullscreen mode

Activate virtual env from directory:

poetry shell
Enter fullscreen mode Exit fullscreen mode

Installing packages

Installing packages:

poetry add <package-name>
Enter fullscreen mode Exit fullscreen mode

From a requirements.txt (more info):

cat requirements.txt | grep -E '^[^# ]' | cut -d= -f1 | xargs -n 1 poetry add
Enter fullscreen mode Exit fullscreen mode

See more useful commands here.

Top comments (0)