Skip to content
hero
Philippe Bordron

Reproducible conda environments

How to export an environment?

You can export an environment as an yaml file that contains the list of packages installed in this environment with the following command:

conda env export > environment.yml

Mixed environments

Only packages installed with conda or pip are taken in account.

If you have installed, for example, some R packages without using conda, please use Renv to manage them.

Resilience

Some packages are sometime deindexed from channels. They always exist but are tagged as unavailable, rendering the environment unable to be reinstalled from the yaml file.

Some alternatives manage this problem:

How to import an environment?

You can restore or install an environment from an yaml file <env-file.yml> with the conda env create command:

conda env create -f <env-file.yml> -p </path/to/my/env>

Environment name

If you forget the option -p (or -n), the environment will be created at ~/.conda/envs/<env>, where <env> is the name of the environment defined into file <env-file.yml>.