Preface: My OS X Python installation is a mess. I started using the system Python way before I found out about Homebrew. And so I\'ve been using sudo
I'm pretty sure that brew reinstall python
somehow fixed a bunch of the issues I was having. I then had to also nuke (i.e., rm -rf
) a few things in /usr/local/lib/python2.7/site-packages
Issue and answer related to my specific use case (ROS installation on OS X): https://github.com/mikepurvis/ros-install-osx/issues/11
Don't use Homebrew nor MacPorts, nor the builtin Python. These are nested solutions that will eventually fail, one way or another (PEP20: flat is better than nested). At the very least, you will have to wait for the package management system to notice any PyPI updates, or fall back to using pip
as you would have done anyway without any package manager. Use MacPorts to install only non-Python items that need to compile and be customized (e.g., ATLAS).
The simplest thing to do is to install a stand-alone Python from python.org (either from a binary distribution, or build from source). No sudo
, install under your user. Then:
pip install -U pip setuptools virtualenvwrapper
Source your wrapper from your ~/.bashrc
per their docs, and makevirtualenv foo
. All other work will be performed in virtual environments only. If you use Python 3, then virtualenv
is part of the interpreter, so you don't need virtualenvwrapper
and the little dance related to it.