Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replicate a conda environment?

I have successfully installed some python code on a Win10 machine using Anaconda and conda environments and would like to install exactly the same environment on another computer, also Win10.

This page indicates that you can save a file that contains the environment info on computer 1, then recall it on computer 2, using:

  1. computer 1: conda list --explicit > spec-file.txt
  2. copy the file from the working directory of computer 1 to the working directory of computer 2
  3. computer 2: conda create --name myenv --file spec-file.txt

Step 1 works fine for me but step 3 fails with a ResolvePackageNotFound error, listing basically all the packages that are in the text file.

Am I missing something? Is there a way to semi-automatically install the packages from that text file instead?

Edit: summary from the answers and comments (thank you!):
  • if conda install was used to install packages in computer 1, then what is written above is the best way to do an exact replication.
  • if pip install was used instead for packages installation (as was the case for me), the chosen solution below is the most appropriate one (conda env export and conda env create)

1 Answers

try using export --

Computer 1 - conda env export > spec-file.yml

Computer 2 - conda env create -f spec-file.yml

like image 91
M S Avatar answered Oct 18 '25 22:10

M S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!