How to Restore Anaconda after Update to MacOS Catalina

 

MacOS Catalina was released on October 7, 2019, and has been causing quite a stir for Anaconda users.  Apple has decided that Anaconda’s default install location in the root folder is not allowed. It moves that folder into a folder on your desktop called “Relocated Items,” in the Security folder. If you’ve used the .pkg installer for Anaconda, this probably broke your Anaconda installation.  Many users discuss the breakage at https://github.com/ContinuumIO/anaconda-issues/issues/10998.

There is unfortunately no simple fix for your current installation. Some people have recommended moving the Anaconda folder from the “Relocated Items” folder back to your home folder, followed by modifying PATH to point at the new location. This is a partial fix, and may restore some core functionality for you.  Unfortunately, many files in a given conda environment contain hard-coded paths to their install path (AKA prefix). When you copy or move folders around, these hard-coded paths are not accurate, and programs in your environment might look for other things in the wrong place and break.

So, where to go from here? You have several options.

Reinstallation

Choose one:

  1. Start fresh with a new Anaconda installation.  Pay attention during installation to make sure that your install path is a subfolder of your home folder, such as /Users/me/anaconda3
  2. Start fresh using the .sh installer instead of the .pkg installer.  This installer makes it simpler to choose the destination path, and gives you more choice on how you want your shell to behave.

We have tested the currently available shell installers, and found them to work fine with Catalina.  If you rely on the GUI installer instead, you’ll need to wait for the soon-to-be-released Anaconda 2019.10 installer, which will be signed and notarized in accordance with Apple’s more stringent policies.

Repair

This is experimental, but will allow you to fix your old installation and keep all of your old environments. To do this, you’ll use our self-contained prefix replacement tool at https://repo.anaconda.com/pkgs/misc/cpr-exec/cpr-0.1.1-osx-64.exe  Note that although these files have a “.exe” file suffix, they are not Windows executables.  We use the .exe suffix to indicate a standalone executable.

The experimental tool uses pyinstaller to make a standalone execution from code at https://github.com/conda/conda-prefix-replacement, which is a consolidated collection of the prefix detection and replacement code that is spread between conda and conda-build.  We’ve added a novel feature to CPR for “rehoming” environments, which is the functionality needed to address the moved environment problem.  Specifically, given the current (new) prefix, rehoming attempts to detect the old prefix from files within, and then adjust the detected files to have the new prefix value. 

In steps:

1. At a terminal, download the file and make it executable:

curl -L https://repo.anaconda.com/pkgs/misc/cpr-exec/cpr-0.1.1-osx-64.exe -o cpr && chmod +x cpr

2. Run the CPR tool to fix embedded paths:

Let’s say you started with an install to /Anaconda3, which Apple helpfully moved to “Relocated Items.”  You have moved that folder to ~/anaconda3. Example commands for using CPR to fix this are:

./cpr rehome ~/anaconda3

Again, that finds your old prefix by looking in some files that are known to record the prefix in a readily parseable way. If that fails, you can still fix things as long as you know what the original path was:

./cpr rehome ~/anaconda3 --old-prefix /Anaconda3

The CPR command is recursive.  Because environments default to the envs folder within your Anaconda[2|3] folder, CPR will fix all of your environments within your base prefix as well. 

3. Re-run conda init to fix your conda shell command:

source ~/anaconda3/bin/activate

conda init

NOTE: if you use a shell other than bash, specify it in the conda init command:

conda init zsh

4. Fix your ~/.conda/environments.txt file:

Open the ~/.conda/environments.txt file, and find/replace all instances of the old install location (e.g. /Anaconda3) with the new one (e.g. ~/anaconda3).

5. Find any remaining references to the old environment in other configuration files:

Many packages in Anaconda manage their own configuration files, typically in some subfolder of your home directory.  You can use a tool like grep or ripgrep to find these files. You’ll then need to edit them and fix the paths as you did with the environments.txt file.  An example grep command might be:

grep -R “/Anaconda3” ~

We hope this helps you get back on track.


You May Also Like

Enterprise Data Science
Here Comes The Data Science—And It’s All Right
Did you know that 94 percent of enterprises are using open source technologies for Data Science, and 96 percent of company executives say Data Science is critical to the succe...
Read More
Enterprise Data Science
Dataversity: Anaconda Enterprise 5 Introduces Secure Collaboration to Amplify the Impact of Data Scientists
http://www.dataversity.net/anaconda-enterprise-5-introduces-secure-collaboration-amplify-impact-data-scientists/...
Read More
For Practitioners
Using Anaconda to Embrace Python 3 And Support Python 2
The data science community received a special delivery in December with the release of Python 3.6. At the time, I had a conversation with The New Stack to discuss wh...
Read More