Poetry Plugin: Export

raw JSON →
1.10.0 verified Sat Apr 11 auth: no python quickstart: stale

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.

pip install poetry-plugin-export
error The command "export" does not exist
cause The `export` command is no longer a built-in feature of Poetry 2.0 and later versions; it has been moved to the `poetry-plugin-export` and must be explicitly installed.
fix
Install the plugin using poetry self add poetry-plugin-export.
error Warning: poetry-plugin-export will not be installed by default in a future version of Poetry. In order to avoid a breaking change and make your automation forward-compatible, please install poetry-plugin-export explicitly.
cause This is a 'future warning' from Poetry (typically versions 1.2.0 to <2.0.0) indicating that the `export` command, previously bundled, will no longer be part of the default Poetry installation in upcoming major versions. It may appear even if the plugin is already installed, as Poetry cannot distinguish between automatically and manually installed plugins for this warning.
fix
Ensure the plugin is installed with poetry self add poetry-plugin-export. To silence the warning after installation, run poetry config warnings.export false.
error Because no versions of poetry-plugin-export match >1.9.0,<2.0.0 and poetry-plugin-export (1.9.0) depends on poetry (>=2.0.0,<3.0.0), poetry-plugin-export (>=1.9.0,<2.0.0) requires poetry (>=2.0.0,<3.0.0). So, because poetry-instance depends on both poetry (1.8.2) and poetry-plugin-export (^1.9.0), version solving failed.
cause The installed version of Poetry is incompatible with the version of `poetry-plugin-export` being attempted for installation; the plugin requires a newer Poetry version than what is currently present.
fix
Update Poetry to a compatible version (e.g., poetry self update) before installing the plugin, or specify a plugin version that is compatible with your current Poetry installation.
error Ensuring that the Poetry plugins required by the project are available... The following Poetry plugins are required by the project but are not installed in Poetry's environment: - poetry-plugin-export (>=1.8) Installing Poetry plugins only for the current project...
cause The `poetry-plugin-export` is declared as a required plugin in your project's `pyproject.toml` file under `[tool.poetry.requires-plugins]`, but it has not been installed into Poetry's self-managed environment.
fix
Install the plugin using poetry self add poetry-plugin-export.
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.
fix Install the plugin using `poetry self add poetry-plugin-export` (for older plugin installation methods) or declare it as a required plugin in `pyproject.toml` under `[tool.poetry.requires-plugins]` for Poetry 2.0+.
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.
fix Ensure your project's Python environment meets the plugin's `requires-python` constraint, which is currently `>=3.10,<4.0` for version 1.10.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.
fix Use `pip install -r requirements.txt --no-deps`.
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.
fix Prefer using `--only <group>` to include only specific groups, or explicitly specify groups with `--with <group>`.
gotcha The plugin requires `poetry.lock` to be consistent with `pyproject.toml`. If the lock file is outdated, the export command might fail.
fix Run `poetry lock` or `poetry update` to ensure `poetry.lock` is up-to-date and consistent before exporting.
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.
fix Update to the latest plugin version to benefit from fixes. Verify exported files in complex dependency scenarios.
breaking Attempting to run `poetry` commands directly in a Python script (e.g., `poetry export -f requirements.txt`) without using `subprocess.run()` or `os.system()` will result in a `SyntaxError`.
fix Execute `poetry` commands from a Python script using `subprocess.run(['poetry', 'export', '-f', 'requirements.txt', '--output', 'requirements.txt'], check=True)` or `os.system('poetry export -f requirements.txt --output requirements.txt')`.
gotcha Attempting to execute shell commands (like `poetry export ...`) directly in a Python script will result in a `SyntaxError`. Shell commands must be invoked using Python's `subprocess` module or by executing the script in a shell environment.
fix To run shell commands from within a Python script, use `subprocess.run(['poetry', 'export', '-f', 'requirements.txt', '--output', 'requirements.txt'], check=True)` or ensure the command is executed directly in your shell/terminal.
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"

The plugin provides an `export` command that integrates directly into the Poetry CLI. You can specify the output format, file, and control which dependency groups are included or excluded. The most common use case is generating a `requirements.txt` for environments that rely on `pip`.

# 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