-1

I factory reset my MacBook and set up everything new to get rid of the multiple python version chaos I had on my old laptop.

Only thing I have installed atm is Anaconda. I created a new conda environment with python 3.9 and activated it in my zsh Terminal.

Still when I type "which python" it shows "/usr/bin/python" containing the MacBook standard Python2.7 version.

How can I make environments use their own dedicated version?

Edit for Code:

conda activate myenvname
which python

Trying to access the folder where the anaconda python should be leads to

cd: no such file or directory: /Users/marcus/anaconda/bin
  • try 'which python3'. Once you have the location of python3, you can set the system var. https://stackoverflow.com/a/3387737/2325014. Or, just type python3 before you run your script or, set your shebang line to the python3 interpreter. – Captain Caveman May 26 '22 at 15:50
  • check, ~/anaconda/bin/python or /Users//anaconda/bin/python. – Captain Caveman May 26 '22 at 15:54
  • 1
    "and activated it in my zsh Terminal. Still when I type "which python" " Could you show an example terminal session? ([As text](https://meta.stackoverflow.com/questions/285551), formatted like code, please.) – Karl Knechtel May 26 '22 at 15:57
  • cd: no such file or directory: /Users/marcus/anaconda/bin did I miss to install anything? – fdushuvcjasdc May 26 '22 at 16:06
  • reinstalling it through the command-line worked! thank you guys for the input! – fdushuvcjasdc May 26 '22 at 16:43

1 Answers1

0

When you install anaconda through the terminal it provides an option to prepend anaconda to the system path. make sure to choose yes. If you don't, you'll need to provide the full path to your anaconda installation when activating an environment, as in:

source <path to conda>/bin/activate
conda init

You'll need to do this in each shell session. Alternatively, you can use the anaconda terminal.

To fix this, Anaconda does not recommend fixing your path manually. I think this is because there are a number of things anaconda does when setting up your shell if you choose "yes". Instead, the recommended fix is to uninstall and re-install anaconda (and pick yes this time ;)).

See the Anaconda docs for more information.

Michael Delgado
  • 13,789
  • 3
  • 29
  • 54
  • I saw somewhere that anaconda was supposed to do that but I wasn't prompted a question. Do I maybe have to install it through terminal instead of the Installer? – fdushuvcjasdc May 26 '22 at 16:09
  • ihre graphical Installer seems to put anaconda into ~/opt but if I try to run source ~/opt/bin/activate it doesn't exist – fdushuvcjasdc May 26 '22 at 16:24
  • Sorry I haven’t used the graphical installer. Tbh I’m more familiar with mini conda than the anaconda installer. But yeah terminal always seems to work for me. Another option is to use the anaconda terminal. – Michael Delgado May 26 '22 at 16:26
  • i will try to reinstall it through terminal! thanks for the help! – fdushuvcjasdc May 26 '22 at 16:31
  • now it doesn't work anymore and the source path/bin/activate fix doesn't help either :/ do you have an idea? all I did was close the terminal – fdushuvcjasdc May 26 '22 at 17:15