tags:
- python
- poetry
title: What is Poetry?
permalink: what-is-poetry
date created: Friday, October 20th 2023, 9:44:07 pm
date modified: Wednesday, May 14th 2025, 9:55:19 am
Poetry is a dependency management and packaging tool for Python projects. It simplifies project setup, dependency resolution, and packaging, making it easier to manage and distribute Python applications.
Install the poetry-plugin-export
to export dependencies into a standard requirements.txt file.
poetry self update
poetry self add poetry-plugin-export
poetry config warnings.export false
On MacOS, Poetry's config.toml
and auth.toml
are located at ~/Library/Application Support/pypoetry
Install project dependencies, including dev dependencies.
poetry install
To install any other dependency group, specify it.
poetry install --with other-group
Install all dependency groups.
poetry install --all-extras
Poetry supports source distribution and wheels.
poetry build
Publish to public or private repositories.
poetry publish
Show the dependency tree.
poetry show --tree
Compare and contrast your dependencies with the latest packages.
poetry show --latest
Poetry can become "confused" when switching between different pyenv versions. You may have to reinstall it with the activated version of Python.
curl -sSL https://install.python-poetry.org/ | python3.11 -
Install poetry-plugin-export as a plugin.
poetry self add poetry-plugin-export
Remove its warning.
poetry config warnings.export false
You can then generate a traditional requirements file from a Poetry TOML file. Here is a Makefile to do so.
REQUIREMENTS = requirements.txt
# Export the requirements with no environment markers.
$(REQUIREMENTS):
@poetry export --without-hashes -f $(REQUIREMENTS) --output $(REQUIREMENTS)
@sed -i '' 's/[[:space:]]*;.*//' $(REQUIREMENTS)
If Poetry times out when fetching packages, try extending its timeout.
export POETRY_HTTP_TIMEOUT=240