简体   繁体   中英

OS X "which python" points to python2.7 instead of Anaconda python3.9

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM