Python in OSX

This is the way I prefer to use Python in OSX as there are few quirks that irritate me.

It has gotten better over the years but still the situation is not that great. It is really painful to install Python packages in OSX compared to what it should be.

What to install

First of all: don’t install anything system-wide if you don’t have to. Usually the only packages I have installed system-wide are:

  • pip
  • virtualenv
  • zc.buildout
  • PIL
  • Mercurial

And these are installed usually in that order. I think pip is currently the best way to handle installation of python packages so it is obviously installed first. Then virtualenv and buildout. Buildout is used in almost all projects when I’m developing something new. Virtualenv is used if I don’t know what I’m doing or I’m just trying out some 3rd party code. Sometimes I run my own (or company) buildout projects inside virtualenv so that I can test different environments.

PIL is in that list only because it is so damn hard to install inside virtualenv. I think it is possible, but it was enough for me to fight with it once.

Notes about installation

First task is to install Apple developer tools. The latest version can be purchased from App Store. Free version of the tools are available in the Mac DevCenter after registration. This is Apple-territory so it is better to get used to the fact that your every move is monitored.

It is possible to do plenty of stuff without the Apple developer tools but usually there comes a point when you need a compiler and then it is handy to have the tools available.

As OSX is officially supported you should get the installation package from the official release. It should install nicely alongside the Apple version.

Then follow the instructions in PIP install guide. Again, quite straightforward. They have easy to use installer script you download and run.

PIL installation instructions are all over the web. Every one of them is slightly different. I can’t believe there isn’t readymade binary package for OSX.