Reputation: 333
I had to reinstall Anaconda due to the Issue with macOS Catalina: how-to-restore-anaconda-after-macos-catalina-update
How can I import my old environments to the newly installed Anaconda-Navigator? (I have not uninstalled the old Anaconda yet)
Upvotes: 2
Views: 3511
Reputation: 383
The problem is Anaconda has previously by default been installed in the root directory folder /anaconda3/
. Catalina no longer accepts root directory folders like this. During Catalina's installation, it moved the Anaconda folder to /Users/Shared/Relocated Items/Security/anaconda3
. The old virtual environments are still there, under the /Users/Shared/Relocated Items/Security/anaconda3/envs/
folder.
The Anaconda Team says that this problem is not that easy to fix, and suggest two approaches: Either reinstall Anaconda, or try to repair the installation. You can find their repair instructions in that link.
If you reinstall, as I did, then there is still no simple way to restore your old environments. While Anaconda has nice functionality to export environments so that you can restore them elsewhere, this functionality requires that you can activate the environment that you want to export — which we can't do here for the old installation moved to the Relocated Items
folder. Still, I found a way to make it work.
If you go into the .../anaconda3/envs/
folder of your old installation, you can see all of your old environments. If you simply copy one of them into the the new installation at /Users/your_user/opt/anaconda3/envs/
, you will be able to activate it in the terminal as
conda activate your_env
This doesn't mean that you can really use these environments. Something as simple as trying to start the Python interpreter will fail, as it's no longer installed where the environment expects it to be. However, you can now export the environment as
conda env export > your_env.yml
This will let you reinstall the environment in the new Anaconda installation so that it matches the environment in the old installation. You can do this by removing the environment and creating it afresh from the your_env.yml
file you just exported:
conda deactivate
conda remove -n your_env --all
conda env create -f your_env.yml
If everything works correctly, this should make your old environment available again. You then just need to do the same thing for every environment that you want to restore.
Upvotes: 1