pyproject2conda

raw JSON →
0.22.1 verified Mon Apr 27 auth: no python

A script to convert a Python project declared in pyproject.toml to a conda environment.yml. Current version 0.22.1, updated monthly by US National Institute of Standards and Technology.

pip install pyproject2conda
error ModuleNotFoundError: No module named 'pyproject2conda'
cause Library not installed.
fix
Run pip install pyproject2conda or conda install pyproject2conda -c conda-forge.
error TypeError: convert() missing 1 required positional argument: 'output'
cause Missing output file argument when calling convert() function.
fix
Use convert('pyproject.toml', 'environment.yml') to specify both input and output.
error ValueError: Invalid pyproject.toml: 'project' section not found
cause The pyproject.toml file does not have a [project] section (PEP 621).
fix
Ensure your pyproject.toml follows PEP 621 format with a [project] table.
gotcha Default output uses conda channels; pip-only dependencies are included via pip section in environment.yml unless --pip-only flag is used.
fix Use --pip-only flag or configure channels in your pyproject.toml.
breaking Configuration file option names changed from dash to underscore in v0.21.0. Old config keys with dashes no longer work.
fix Replace dashes with underscores in config file keys (e.g., 'output-file' -> 'output_file').
deprecated Python 3.9 support was dropped. Requires Python >=3.10 as of v0.22.0.
fix Upgrade Python to 3.10 or later.
conda install pyproject2conda -c conda-forge

Convert pyproject.toml to conda environment.yml

from pyproject2conda import convert
convert('pyproject.toml', 'environment.yml')