transfer packages from one conda environment to another

Viewed 2593

I am new in the Unix environment.I have a small problem, due to some problem which i don't really get I had to create an new Conda environment and now I wonder if I can transfer all the packages from my old environment to the new (or i need to install them again? )

thanks in advance for your help

1 Answers

If you want to duplicate an env (say foo_env) in a new env (bar_env) you can use

conda create --clone foo_env --name bar_env

If you already have a new env (bar_env), and want to install packages from an existing env (foo_env) you can use

conda env export --name foo_env > foo.yaml
conda env update --name bar_env --file foo.yaml

Note that the conda env commands don't prompt for changes, so make sure to check the foo.yaml to verify that you really do want all the packages installed. Be aware that it will replace any duplicate packages if it involves a version change.

Related