Upgrading to OS X Mavericks (10.9) broke my Python development environment by deleting the contents of /Library/Python/2.7/site-packages and X11. Why an OS upgrade should be deleting things I put there is another question, but here’s how to get back up.
My Mac Python setup is reasonably standard I think: I use a system-wide install of some basic stuff (virtualenv, pip, easy_install) and then virtualenvs for all development.
After upgrading, existing virtualenvs were fine – the problem started when I wanted to create a fresh one. Suddenly virtualenv wasn’t there, and once virtualenv had been restored pip found it impossible to build several of the libraries that I depend on (including Pillow, lxml, gevent – basically anything with a C library dependency).
Step 1: Get virtualenv back
cd /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command python easy_install.py virtualenv
Step 2: Create a virtualenv and try installing the modules you need
virtualenv <path> pip install -r <your requirements file>
If all installs fine, then you’re done! If like me you get errors, here’s some of the things that are probably missing:
Step 3: Reinstall X11 (required for Pillow / PIL)
Download from XQuartz.org
Step 4: Reinstall XCode command line tools
Install the latest XCode (currently 5.0.1) then install the command line tools:
Step 5: Repair homebrew
If you’re using Homebrew for access to various open source packages – and I strongly recommend you do – then you may need to repair things.
brew update brew upgrade brew doctor
and follow the recommendations
After all this, you should find you’re back where you were before Mavericks, and able to build and install Python modules. Happy hacking!