On using conda

less than 1 minute read

Environment export

Create a clean environment file using:

conda env export --from-history

Including packages installed from additional channels

By default this does not include packages that were installed using the form conda install -c CHANNEL PACKAGE, e.g. it does not work for PyTorch.

A solution, provided in this StackOverflow answer is to first add the desired channels to the environment via:

conda activate <MY_ENV>
conda config --env --add channels <CHANNEL>

One can then install the desired packages without the -c PACKAGE option and those will be added to the environment generated using the --from-history flag, as well as the channels.