8

Is there a definitive guide for how to install Homebrew's Python properly, along with pip, virtualenv, virtualenvwrapper etc.?

I've read the following pages:

https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
http://osxastrotricks.wordpress.com/2012/05/02/python-setup-with-homebrew/
http://skipperkongen.dk/2011/11/13/installing-django-in-virtual-environment-on-mac/
http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/
http://youshoulddoityourself.blogspot.com.au/2010/11/test.html

I have OSX 10.8 (Mountain Lion) DP3, and I installed the XCode Command Line Tools.

I also installed XQuartz as well, just in case (10.8 doesn't provide it).

I then ran:

brew install python  --universal --framework

I added the following to my ~/.bash_profile:

export PATH="/usr/local/bin:/usr/local/share/python:${PATH}"

I then ran:

sudo easy_install pip

which seemed to work.

I check where pip's installed:

 Victors-MacBook-Pro:~ victorhooi$ which pip
/usr/local/bin/pip

However, when I try to pip install packages, I get an error complaining about not being able to write to /Library/Python/2.7/site-packages:

running install_lib

creating /Library/Python/2.7/site-packages/yolk

error: could not create '/Library/Python/2.7/site-packages/yolk': Permission denied

----------------------------------------
Command /usr/bin/python -c "import  setuptools;__file__='/Users/victorhooi/build/yolk/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/gg/m37t1rkx4zj7z54ls487jfc40000gn/T/pip-ap7LSB-record/install-record.txt failed with error code 1 in /Users/victorhooi/build/yolk
Storing complete log in /Users/victorhooi/Library/Logs/pip.log

My understanding was that Homebrew's Python would install into it's own site-packages, and I wouldn't need to do weird chown's all over the filesystem tree to get things to work?

Cheers, Victor

4

3 回答 3

10

同时,homebrew 的 python 也进化了:

  • 通过 brew 安装的 Python 不再尝试写入/Library/Python.
  • Homebrew 的 Python 现在总是使用自己的站点包。
  • pip(和分发)是自动安装的。
  • 不需要“--framework”选项。Homebrew 现在默认使用它。
  • 需要 XQuartz(不幸的是)因为 Tk 标头链接到 X11 标头。

.bashrc 中的 PATH 是正确的(并且仍然需要)。

于 2012-08-15T08:36:00.153 回答
2

请作为一直在您所在位置的人,首先开始使用虚拟环境,然后是 pip 和其余部分。他们很棒,将解决这个问题和许多未来的问题。

于 2012-06-07T09:16:26.380 回答
-1

现在有了 Mountain Lion 10.8.2 并且我从 Lion 安装了旧版 Python 2.7,但一切都无法正常工作。无论我尝试什么,Python 都想访问 /Library/.. 不好。简单的解决方案是brew uninstall python,然后brew install python解决几乎所有与 ML 上的 homebrew 相关的 Python 相关问题。

于 2012-09-28T21:19:14.007 回答