I have a conda environment that I would like to convert to a poetry environment.
What I have tried is to translate the environment.yaml of the conda environment into a pyproject.toml file that poetry can read. Here you have the steps:
Generate the yaml file
conda env export --from-history > environment.yamlThe
--from-historyflag includes only the packages that I explicitly asked for. Here it is how the file looks like after installing numpy.# environment.yaml name: C:\Users\EDOCIC\Screepts\My_projects\Tests\conda2poetry\condaenv channels: - defaults dependencies: - numpyManually create the
pyproject.tomlfile out ofenvironment.yaml. I added the numpy version, which I got fromconda env export. Here it is the result:# pyproject.toml [tool.poetry] name = "conda2poetry" version = "0.1.0" description = "" authors = [""] [tool.poetry.dependencies] python = "~3.7" numpy = "^1.21.5" [tool.poetry.dev-dependencies] [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api"Create the environment with
poetry init, which will automatically read the toml file.
The process seems to work but it's quite manual and prone to mistakes. Is there a better way?