Mac using default Python despite Anaconda install

主宰稳场 提交于 2019-12-02 15:09:42

The first matching executable is the one that is run. From what I can gather you are concatenating your PATH variable in such a way that:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

comes before:

$HOME/anaconda/bin

So make sure that the anaconda directory is the first one, meaning that it will have precedence:

export PATH="$HOME/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH"

If you are using fish, you can find Anaconda backup your old .bash_profile as .bash_profile-anaconda.bak, and it added 2 lines at the bottom of .bash_profile which looks like this:

# added by Anaconda2 4.1.1 installer
export PATH="/Users/username/anaconda/bin:$PATH"

However fish does not read it, so you have to add it in fish config file manually, which is in ~/.config/fish/config.fish:

set -x PATH /Users/username/anaconda/bin $PATH

if you are using zsh you can edit in your zshrc file in your root folder to include

export PATH="$HOME/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH"

If you use LiClipse or Eclipse as your IDE, the Preferences menu will allow this management process to go much easier. But I understand the joy of the command line.

It is super easy to make Anaconda, or rather Anaconda's Python version the default interpreter in LiClipse, as well as call the site-packages from Anaconda. I just set it up today.

Regards,

JF

Update for all people seeing this with Python 3: above solutions will not work with Python 3.

Anaconda's Python 3 is now at ~/anaconda3/bin. So instead do:

export PATH="$HOME/anaconda3/bin:$PATH"

or

export PATH="$HOME/anaconda3/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH"

Make sure you are using the full path: - don't use "~" instead of the root:

(wrong)

export PATH="~/anaconda/bin:$PATH"

(Correct)

export PATH="$HOME/anaconda/bin:$PATH"

This change worked for me!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!