如何使用安装了brew的Python作为默认Python?

2024-06-08 13:32:19 发布

您现在位置:Python中文网/ 问答频道 /正文

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

brew install python 

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

which python

给我

/usr/bin/python

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

如何使python brew flavor成为我的默认python?


Tags: install实用程序whichbinos链接macusr
3条回答

在使用自制程序时,以下命令提供了更好的图片:

brew doctor

输出:

==> /usr/bin occurs before /usr/local/bin This means that system-provided programs will be used instead of those provided by Homebrew. This is an issue if you eg. brew installed Python.

Consider editing your .bash_profile to put: /usr/local/bin ahead of /usr/bin in your $PATH.

快速修复:

  1. 打开/etc/paths
  2. 更改行的顺序(优先级最高)

在我看来/etc/paths看起来像:

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

如果您想了解更多有关OSX中路径的信息,我发现这篇文章非常有用:

http://muttsnutts.github.com/blog/2011/09/12/manage-path-on-mac-os-x-lion/

见:How to symlink python in Homebrew?

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

相关问题 更多 >