Poetry Plugin: Export
poetry-plugin-export is an official Poetry plugin, currently at version 1.10.0, that extends Poetry's functionality by providing an `export` command. This command allows users to convert locked dependencies from `poetry.lock` files into various standardized formats such as `requirements.txt`, `constraints.txt`, and `pylock.toml`. It aims to eventually replace the functionality of Poetry's built-in `export` command (which is no longer bundled by default in Poetry 2.0+). The plugin is actively maintained, with releases tied to the evolution of Poetry itself.
Warnings
- breaking As of Poetry 2.0, the `poetry export` command is no longer bundled by default with Poetry. Users must explicitly install `poetry-plugin-export` to regain this functionality.
- breaking Python 3.9 support was dropped in `poetry-plugin-export` version 1.10.0. Python 3.8 support was dropped in 1.9.0, and Python 3.7 support in 1.5.0.
- gotcha When installing an exported `requirements.txt` file via `pip`, always pass `--no-deps`. Poetry has already resolved all direct and transitive dependencies, and `pip` trying to re-resolve can lead to failures, especially with git dependencies.
- deprecated The `--without` option for excluding dependency groups was deprecated in version 1.9.0. While still functional, it's recommended to use `--only` or explicitly list `--with` groups for clarity.
- gotcha The plugin requires `poetry.lock` to be consistent with `pyproject.toml`. If the lock file is outdated, the export command might fail.
- gotcha Editable installs and git dependencies have had issues with correct export in past versions. While some fixes were implemented (e.g., 1.8.0 for editable, 1.6.0 for git commit hashes), ensure your specific setup works as expected.
Install
-
poetry self add poetry-plugin-export -
pipx inject poetry poetry-plugin-export -
# In pyproject.toml for Poetry 2.0+: [tool.poetry.requires-plugins] poetry-plugin-export = ">=1.8" -
pip install poetry-plugin-export
Quickstart
# Assuming a pyproject.toml and poetry.lock exist in the current directory # and poetry-plugin-export is installed. # Export to a standard requirements.txt file poetry export -f requirements.txt --output requirements.txt # Export with development dependencies and without package hashes poetry export -f requirements.txt --output dev_requirements.txt --with dev --without-hashes # Export to a constraints.txt file including all dependency groups poetry export -f constraints.txt --output constraints.txt --all-groups