LinuxCommandLibrary

poetry

Python dependency management and packaging tool

TLDR

Create new project

$ poetry new [project-name]
copy
Initialize in existing directory
$ poetry init
copy
Install dependencies
$ poetry install
copy
Add a package
$ poetry add [package]
copy
Remove a package
$ poetry remove [package]
copy
Run a command
$ poetry run [command]
copy
Activate virtual environment
$ poetry shell
copy

SYNOPSIS

poetry [command] [options]

DESCRIPTION

poetry is a Python dependency management and packaging tool that uses pyproject.toml as its single configuration file. It handles dependency resolution, virtual environment management, building, and publishing packages to PyPI.
Poetry creates isolated virtual environments for each project and uses a lock file (poetry.lock) to ensure reproducible installations across different machines. Key commands include install (install dependencies), add/remove (manage dependencies), run (execute in venv), and shell (activate venv).

PARAMETERS

new NAME

Create new project.
init
Initialize interactively.
install
Install dependencies.
add PKG
Add dependency.
remove PKG
Remove dependency.
run CMD
Run command in venv.
shell
Spawn shell in venv.
update
Update dependencies.

CONFIGURATION

pyproject.toml

Project configuration file containing dependencies, metadata, build system settings, and Poetry-specific settings under `[tool.poetry]`.
poetry.lock
Lock file ensuring reproducible dependency resolution across installations.
~/.config/pypoetry/config.toml
Global Poetry configuration including virtualenv settings, repository credentials, and cache paths.

CAVEATS

Requires Python 3.8+. Uses its own virtual environments.

HISTORY

Poetry was created as a modern Python dependency management solution.

SEE ALSO

pip(1), pipenv(1), python(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard