poetry(1)
Poetry is a Python dependency manager and packaging tool that simplifies project setup, dependency resolution, and package distribution.
Synopsis
poetry [OPTIONS] COMMAND [ARGS]...Description
Poetry manages Python project dependencies and virtual environments, replacing pip, venv, and setup.py. It uses a pyproject.toml file to declare project metadata and dependencies, automatically resolving version conflicts and creating lock files for reproducible installs.
Poetry handles the complete Python packaging workflow: creating new projects, adding/removing dependencies, building distributions, and publishing to PyPI. It creates isolated virtual environments per project and provides straightforward commands for everyday development tasks.
Common options
| Flag | What it does |
|---|---|
--version | Show Poetry version and exit |
-v, --verbose | Increase output verbosity (use -vv or -vvv for more detail) |
-q, --quiet | Suppress output messages |
--no-interaction | Run in non-interactive mode without prompts |
--no-cache | Ignore cached packages and force fresh downloads |
--directory DIR | Specify project directory (default: current directory) |
Examples
Create a new Poetry project with default structure in a myproject directory
poetry new myprojectAdd the requests package to project dependencies and update lock file
poetry add requestsAdd pytest as a development dependency (not needed for production)
poetry add pytest --group devInstall all dependencies from pyproject.toml and poetry.lock into virtual environment
poetry installExecute a Python script within the project's virtual environment
poetry run python script.pyUpdate all dependencies to latest compatible versions and regenerate lock file
poetry updateBuild wheel and source distribution packages for publishing
poetry buildPublish built packages to PyPI (requires authentication)
poetry publish