How to backup Anaconda added packages?
Asked Answered
A

2

10

I have Anaconda for Python 2, It came packed with a lot of useful packages. During my work, I have added several packages to it using conda install command. Now I have to format my system, and I want to backup/pack all the added libraries, either as full packages or even by knowing the installation command of each one.

I searched StackOverflow, I found one unanswered question with a similar problem, the question suggested conda list -e >file_list.txt to create a file contains all the installed packages, but this is not sufficient for me, I want Anaconda to determine which package is added by me, and by which command, or to pack the added packages in full.

Thanks for help.

Accipitrine answered 22/5, 2017 at 12:6 Comment(0)
V
22

I think you can find the solution you are looking for here.

  • Open the Anaconda prompt
  • Activate the environment you are interested in
  • Type conda env export > environment.yml

In the yml you will find all the dependencies and you can use it to create a new virtual environment as a copy of the current one.

For example, on the new/rebooted machine, you can do:

conda env create -f environment.yml
Vining answered 22/5, 2017 at 12:26 Comment(3)
Thank @Flab you for your answer I tried it, but it retured the following error: usage: conda-script.py [-h] [-V] command ... conda-script.py: error: argument command: invalid choice: 'C:\\Anaconda2\\Scripts\\conda-script.py' (choose from u'info', u'help', u'list', u'search', u'create', u'install', u'update', u'upgrade', u'remove', u'uninstall', u'config', u'clean', u'package')Accipitrine
OK, There is a typo in the line you provided, the correct command is conda env export > environment.ymlAccipitrine
I got it, we should first activate the environment even it is the root environment, by the command activate root, then we should type the command conda env export > c:\environment.yml (to put the exported environment at c:`. After that in the new machine, type conda env create -f environment.yml`, to create the new environment.Accipitrine
Y
0

Just to provide another insight. I encountered the same problem and tried the solutions provided but it didn't work. I could not export my environment as a backup no matter what I did. But it turns out, it was due to the Antivirus on my laptop which was auto-blocking important services, one of which was related to the Anaconda that I was using. Hope this might also help solve the same problem if the previous solution didn't work. Thanks!

Yoo answered 7/10, 2023 at 15:9 Comment(1)
This is an appreciated insight. But in order to turn your post into a helpful answer, it would be an improvement if you could add how you solved that version of the problem. In my opinion the "obvious" solution to turn off the antivirus is not acceptable.Quake

© 2022 - 2025 — McMap. All rights reserved.