27

I've just updated my MacBook to Catalina. After the update, zsh can't find anymore. In fact, in my .zshrc I had:

export PATH=/anaconda3/bin:$PATH

However, the path /anaconda3/bin doesn't exist anymore. Does that mean that I have lost all of my environment?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
user1315621
  • 3,044
  • 9
  • 42
  • 86
  • Apple is assaulting open-source, and especially Machine Learning and Data Science users. There seems to be a solution that will be out soonish... but so far you're stuck with the hack below. – linhares Nov 20 '19 at 05:20

11 Answers11

40

You can find the entire anaconda3 environment in a shortcut link named 'Relocated Items' on your desktop. It appears as though the upgrade to Catalina does not allow the Conda environment to be installed under a user directory now likely having to do with the new system volume move to a read-only partition.

This issue has been opened as far back as June 10th, I am a little disappointed that it was not resolved before the Catalina upgrade came around.

There is a solution that appears to work without losing your environment, see this link: https://github.com/ContinuumIO/anaconda-issues/issues/10998#issuecomment-539215005

From the link:

  1. Copy the folder anaconda3 located in Relocated Items to /Users/myname/

  2. Open Terminal

  3. Enter: export PATH='/Users/myname/anaconda3/bin:$PATH'

  4. Enter: conda init zsh

  • 1
    After following the steps to move the `anaconda3` directory, I found that `jupyter notebook` kernel was crashing. I had to manually change the launcher arguments in `/Users/[myusername]/Library/Jupyter/kernels/python3/kernel.json`. – C. Braun Oct 09 '19 at 18:10
  • 4
    This isn't working for me, I'm still getting a `zsh: /Users/me/anaconda3/bin/conda: bad interpreter: /anaconda3/bin/python: no such file or directory` error when I run `conda init zsh`. Is there anything else I can do? – Kyle Frye Oct 15 '19 at 16:33
  • 3
    I think the export command needs double quotes ie `export PATH="/Users/myname/anaconda3/bin:$PATH"`otherwise `$PATH` won't get substituted correctly and all your old path locations will disappear – codebox Nov 02 '19 at 13:31
  • 4
    for the issue that Kyle had, you have to replace the first line in the anaconda3/bin/conda file with #!/Users//anaconda3/bin/python – Talik Nov 20 '19 at 17:37
  • I tried all of this, it didn't work. After trying this I literally entered /Users//anaconda3/bin and double-clicked on the file activate – JOSE DANIEL FERNANDEZ Feb 15 '20 at 05:47
  • 1
    should be double quoted... export PATH="/Users/myname/anaconda3/bin:$PATH" – krinker Apr 26 '20 at 19:40
10

Anaconda has published a blog post on the issue. There seem to be two main options:

  1. Reinstallation: for now shell installer only (you’ll need to wait for the new installer if you rely on the GUI instead).

  2. Repair (experimental): will allow you to fix your old installation and keep all of your old environments

You can check the Anaconda website for further information.

Kaymal
  • 556
  • 3
  • 15
6

None of the existing answers worked for me but this one does.

  1. Download anaconda's self-contained prefix replacement tool at https://repo.anaconda.com/pkgs/misc/cpr-exec/cpr-0.1.1-osx-64.exe 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. Move your anaconda3 folder from Relocated Items to your home folder: ~/anaconda3.

  3. Fix your folder using the following command:

    ./cpr rehome ~/anaconda3
    
  4. Re-run conda init to fix your conda shell command:

    source ~/anaconda3/bin/activate
    
    conda init
    

If you are using zsh,replace the last command with:

conda init zsh
Josmy
  • 408
  • 3
  • 12
  • 1
    This also worked for me. This is the approach recommended by Anaconda. https://www.anaconda.com/how-to-restore-anaconda-after-macos-catalina-update/ – Danny Meyer Jan 02 '20 at 14:48
3

If you are using zsh, conda installer adds a conda init script at the end of your ~/.bash_profile file. You should copy it and paste into your ~/.zshrc file.

keser
  • 2,472
  • 1
  • 12
  • 38
3

Copy anaconda3/ path to /Users/<my_user>/

Then export PATH='/Users/<my_user>/anaconda3/bin:$PATH'

Edit file:

  • /Users/<my_user>/anaconda3/conda

Edit the first line like:

FROM #!//anaconda3/bin/python
TO  #!/Users/<my_user>/anaconda3/bin/python

Save changes to /Users/<my_user>/anaconda3/bin/conda init zsh

Should work

Eden
  • 76
  • 3
2

use this (do not use double " )

export PATH='/Users/myname/anaconda3/bin:$PATH'
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
Jhixx
  • 21
  • 1
2

There is now a fix from anaconda.

Another key change since the last release is that Apple released macOS version 10.15 – Catalina. Unfortunately, this was a breaking release for previous versions of Anaconda that used the pkg installer. The Anaconda Distribution 2019.10 installers address the issues and should install without trouble on macOS Catalina. If you would rather repair your current Anaconda installation, please check out this blog post for tips.

https://www.anaconda.com/anaconda-distribution-2019-10/

  1. Delete old installs first.
  2. Install the new 2019.10+ distro.
  3. Open Terminal/cmd Test out conda -V
  4. Test out jupyter notebook

Everything worked perfectly for me, no need to change paths or anything.

Steven Barnard
  • 514
  • 7
  • 12
1

I was able to develop a workaround for this issue by installing miniconda from Homebrew (https://brew.sh/). After installing Homebrew, type the following into Terminal:

brew cask install miniconda

Once miniconda is installed, conda commands should be accessible through Terminal and you may also want to run conda update conda to ensure the packages in your environment are consistent.

Finally, you may have to change your approach to opening Anaconda tools such as Jupyter Notebook. Such tools can be accessed via Terminal with the prefix conda run ...

For example:

conda run jupyter notebook

will open Jupyter Notebook, but the command

jupyter notebook

might not work. A similar question was asked on this post.

Chase
  • 156
  • 1
  • 4
  • Thanks for pointing out that the new command to start the notebook is `conda run jupyter notebook`. That did it for me. – kavini Nov 12 '19 at 03:21
0

I followed this post and it worked (I did it for python 3). Summary of steps:

  1. Relocate anaconda3 folder from Relocated Items to you home
  2. Download the the command line installer for Anaconda3
  3. Make the install script executable (chmod +x)
  4. Run the installer with the -u option to upgrade an existing Anaconda installation:

    ./<name of anaconda installer> -u

  5. add this line to your .bash_profile:

    export PATH="/Users/<username>/anaconda3/bin:$PATH"

matt525252
  • 642
  • 1
  • 14
  • 21
0

I installed the anaconda successfully through command mode, still was not running.

So, conda was installed but not activated.

My steps to solution:

  1. restart computer
  2. source ~/anaconda/bin/activate

(in terminal; activation needs to run successfully)

  1. conda init

(needs to run without any error)

  1. conda config --set auto_activate_base True

(this will activate conda automatically to run conda)

  1. if you don't want auto activation, give the argument "False" instead of "True". each time before running conda, you will have to execute "conda init"

This also solved another problem - my spyder was not running from navigator. Now it's running fine.

If it does not work, let me know.

Reza
  • 1
  • 1
0

This Commands works for me :

$ export PATH='/opt/anaconda2/bin:$PATH'
$ conda init zsh
Muneerah Rashed
  • 313
  • 3
  • 13