Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Conda and Virtualenv to work on mac OS Catalina?

I previously had Conda running smoothly on Mojave, but I've found that the upgrade to Catalina moves the "anaconda3" folder to your Desktop > Relocated Items > Security > anaconda3. It seems Catalina's security settings may not allow applications to install directly under the user directory anymore.

I tried the suggestion here, written below:

Hi, I might have a solution

  • Copy the folder anaconda3 located in Relocated Items to /Users/myname/
  • Open Terminal
  • Enter: export PATH=''/Users/myname/anaconda3/bin:$PATH"
  • Enter: conda init zsh

It worked! Good luck!

But this doesn't work for me. After conda init zsh I get:

-bash: /Users/USER/anaconda3/bin/conda: /anaconda3/bin/python: bad interpreter: No such file or directory

How can I get Conda up and running again without losing all my virtual environments? Thanks!


Update

I got Conda to work following @Ted Shaowang's suggestion. This means that conda env list shows all the virtual environments created via Conda.

However I am still experiencing an issue with virtualenv as since I changed the default anaconda3 file locations, python cannot be found.

The python executable located at .virtualenvs/env/bin/python cannot be found. Do I need to make further changes in order for python to work from virtualenv too?

like image 321
rrz0 Avatar asked Oct 08 '19 20:10

rrz0


People also ask

Where is Virtualenv installed on Mac?

It will get installed in the venv/ folder, and not conflict with other projects.


Video Answer


2 Answers

I have the exact same problem and this works for me:

After you move anaconda from "Relocated Items" to ~/anaconda3, edit the first line of ~/anaconda3/bin/conda file from #!/anaconda3/bin/python to #!/Users/USERNAME/anaconda3/bin/python to reflect the change.

like image 166
Ted Shaowang Avatar answered Oct 20 '22 21:10

Ted Shaowang


I would probably abstain from using the above solution. That ~/anaconda3/bin directory has lots of runnables (not just the conda one) that would need to be altered in this manual way. For example, unless you make the same change you cannot run jupyter notebook either, neither from base nor from other envs you might have.

My tip: Try getting a requirements file for your virtual envs, and do a fresh installation. You could use pipreqs to get the requirements used for individual projects: https://www.idiotinside.com/2015/05/10/python-auto-generate-requirements-txt/

like image 3
Cristina Morariu Avatar answered Oct 20 '22 22:10

Cristina Morariu