$linuxjunkies
>

poetry(1)

Poetry is a Python dependency manager and packaging tool that simplifies project setup, dependency resolution, and package distribution.

UbuntuDebianFedoraArch

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

FlagWhat it does
--versionShow Poetry version and exit
-v, --verboseIncrease output verbosity (use -vv or -vvv for more detail)
-q, --quietSuppress output messages
--no-interactionRun in non-interactive mode without prompts
--no-cacheIgnore cached packages and force fresh downloads
--directory DIRSpecify project directory (default: current directory)

Examples

Create a new Poetry project with default structure in a myproject directory

poetry new myproject

Add the requests package to project dependencies and update lock file

poetry add requests

Add pytest as a development dependency (not needed for production)

poetry add pytest --group dev

Install all dependencies from pyproject.toml and poetry.lock into virtual environment

poetry install

Execute a Python script within the project's virtual environment

poetry run python script.py

Update all dependencies to latest compatible versions and regenerate lock file

poetry update

Build wheel and source distribution packages for publishing

poetry build

Publish built packages to PyPI (requires authentication)

poetry publish

Related commands