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)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay