Poetry is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Poetry offers a lockfile to ensure repeatable installs, and can build your project for distribution.
INSTALL on Linux & macOS
curl -sSL https://install.python-poetry.org | python3 -
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
VERIFY Installation
poetry --version
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
UPDATE Poetry itself
poetry self update
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
UNINSTALL Poetry
curl -sSL https://install.python-poetry.org | python3 - --uninstall
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
Setup NEW Project
poetry new poetry-demo
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
PS: poetry-demo should be the name of your project
...the command creates a directory poetry-demo with the following content:
poetry-demo
├── pyproject.toml
├── http://README.md
├── poetry_demo
│ └── __init__.py
└── tests
└── __init__.py
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
PS: pyproject.toml is the most important file here. And it looks like this:
[tool.poetry]
name = "poetry-demo"
version = "0.1.0"
description = ""
authors = [ "JJOKAH <jjokah.pm.me>" ]
readme = "README.md"
packages = [{include = "poetry_demo" }]
[tool.poetry.dependencies]
python = "^3.9"
[tool.poetry.dev-dependencies]
black = "^21.9b0"
[build-system]
requires = ["poetry-core> = 1.0 . 0 "]
build-backend = "poetry.core.masonry.api"
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
INTIALISE a pre-existing project
cd pre-existing-project
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
poetry init
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
PS: this interactively creates a pyproject.toml file in the directory - pre-existing-project
SPECIFY and ADD dependencies
...in the pyproject.toml file under the tool.poetry.dependencies section, specify your package like this:
[tool.poetry.dependencies]
pendulum = "^2.1"
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
...OR use this command:
poetry add pendulum
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
VERSION constraints
...in the example above pendulum="^2.1" means
install the pendulum package with a version greater than 2.1.0 and less than 3.0.0 (>=2.1.0 <3.0.0)
DEV dependencies
specify with --dev to add a package for the development environment only and not in Production:
poetry add black --dev
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
... black package will be added to the tool.poetry.dev-dependencies section
[tool.poetry.dev-dependencies]
black = "^21.9b0"
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
INSTALL dependencies
poetry install
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
UPDATE dependencies
poetry update
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
ACTIVATE the virtual environment
poetry shell
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
DEACTIVATE / exit the environment
exit
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
⚽ Live Match: jjokah/installing poetry the intuitive python dependency manager ib - Info Live Streaming 2026
Now, we are all set with #python poetry 🥂.
Top comments (0)