Homebrew Python and an entry in / Library / Python / 2.7 / site-packages /?

Is there a definitive guide to installing Homebrew Python correctly, along with pip, virtualenv, virtualenvwrapper, etc.

I 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, just in case (10.8 does not provide it).

Then I ran:

brew install python --universal --framework 

I added the following to ~/.bash_profile :

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

Then I ran:

 sudo easy_install pip 

which seemed to work.

I check where pip is installed:

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

However, when I try to install install packages, I get an error message that is at a loss that you cannot 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 Python would install its own site packages in it, and I would not have to weirdly roll around the entire file system tree to make it work?

Cheers, Victor

+8
python homebrew
source share
3 answers

Please, as someone who was exactly where you are, first start using virtual environments, then click and the rest. They are amazing and will solve this and many future problems.

+2
source share

At the same time, home python has evolved:

  • Python installed via brew no longer tries to write to /Library/Python .
  • Homebrew Python now always uses its own site packages.
  • pip (and distribution) is installed automatically.
  • The -framework option is not required. Now Homebrew is the default.
  • XQuartz is necessary (unfortunately) because Tk headers refer to X11 headers.

Your PATH in .bashrc is correct (and still necessary).

+10
source share

Now that there is Mountain Lion 10.8.2, and I have an outdated version of Python 2.7 from Lion, it just doesn't work. No matter what I tried, Python wanted to access / Library / .. Not good. A simple solution is brew uninstall python and then brew install python . Solves almost all Python-related issues with homebrew on ML.

-one
source share

All Articles