我尝试在Mac OS X 10.6.2上切换到Homebrew(在使用fink和macport后)。我已经安装了python 2.7

brew install python 

问题是,与Macport相反,似乎没有python_select实用程序,我的默认mac python总是默认的

which python

给我

/usr/bin/python

而且/usr/bin/python不是符号链接

我怎么做才能使python酿造风味成为我的默认python ?


当前回答

您需要编辑您的PATH环境变量,以确保在/usr/bin之前搜索自制python所在的位置。你也可以在你的shell配置中设置一些东西,让一个像PYTHON这样的变量被设置为你想要的PYTHON版本,并从命令行调用$PYTHON而不是PYTHON。

另外,正如另一个帖子所述(特别是在mac上),不要混淆/usr/bin中的python,将其指向另一个python安装。你这样做是在自找麻烦。

其他回答

将/usr/local/opt/python/libexec/bin显式添加到.bash_profile:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

在那之后,它应该能正常工作。

如果你是鱼壳

echo 'set -g fish_user_paths "/usr/local/opt/python/libexec/bin" $fish_user_paths' >> ~/.config/fish/config.fish
brew link python

你必须为python创建/添加一个别名,并将其放在你的.zprofile中(位于Users/username文件夹中,如果你按Shift+command+。

这必须指向您的自制python安装位置。

alias python ='opt/homebrew/bin/python3'

参见:如何在Homebrew中使用python符号链接?

$ brew link --overwrite python
Linking /usr/local/Cellar/python/2.7.3... 28 symlinks created
$ which python
/usr/local/bin/python

修改你的$PATH,在bashrc或bash_profile中添加:

export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH

更多信息请点击这里: 问题# 89791