Poetry
Definition
Poetry manages Python dependencies, virtual environments, and packaging through a single declarative pyproject.toml, replacing the older requirements.txt + pip + venv workflow.
Core Ideas
Virtual environments
Poetry creates and manages a per-project virtual environment automatically. The easiest way to activate it is a nested shell:
poetry shellRun one-off commands inside the environment with poetry run <cmd>.
Migrating from requirements.txt
Import an existing project’s pinned dependencies into Poetry in one line:
poetry add $(grep -v '^#' requirements.txt)(The grep -v '^#' strips comment lines.) From then on, poetry add / poetry remove update pyproject.toml and the lock file.
Relationships
- Django — Poetry is a common way to manage a Django project’s dependencies
- Software Engineering Practices — reproducible environments as an engineering habit
References
- Poetry — Basic Usage
- Import requirements.txt using Poetry (Stack Overflow)