How to back up anaconda environment in Windows 10?

2019-08-06 06:15发布

问题:

Recently, my anaconda environment got broken due to certain bad conda package upgrade. Due to this back experience, I would like to back up my anaconda environment for future easy recovery.

What I did to back up was to zip up the entire folder at C:\ProgramData\Anaconda3. Is this the correct way?

I am using Windows 10, anaconda python v3.6 64-bit.

回答1:

It doesn't really make sense to zip up a conda environment for back up purposes since there are other ways to do this which may be more appropriate and use the in-built functions designed to do just this.

You can create a .txt version of the conda environment that details each module and version within, and can then be used to re-create the EXACT environment in the future.

# Create list of the environment
conda list --explicit environment_backup.txt

# Use the newly created text file to recreate the environment
conda create --name my_env_name -- file environment_backup.txt

See docs for more information on managing conda environments.

N.B. As an additional point, conda environment directories can be fairly large (often >1GB) whereas the txt file created here is ~25KB, offering a clear advantage when archiving something for safe-keeping.