First, you almost always want to use pip
instead of easy_install
whenever possible. And "whenever possible" pretty much means "for everything except pip
itself, and readline
." Apple doesn't pre-install pip
, but you can just sudo easy_install pip
and then everywhere you'd sudo easy_install foo
instead sudo pip install foo
.
Second, pycairo
requires Python 3.1+. You want py2cairo
, the version for Python 2.6-2.7. Since there is no PyPI package for this, you have to either download it or git clone it manually. But fortunately, pip
does this for you automatically: sudo pip install http://cairographics.org/releases/py2cairo-1.10.0.tar.bz2
or sudo pip install git+https://git.cairographics.org/git/py2cairo
.
Unfortunately, not everything can be installed by either pip
or easy_install
. If either one fails, you have to read the PyPI page, home page, or documentation for the project.
In the case of pycairo
, the reason it can't be easy_install
/pip install
ed is that it's built using waf
instead of distutils
(and nobody has written a distutils
wrapper around the waf
build). But you don't really care why it doesn't work, just what you have to do.
Well, the instructions tell you what you have to do. You may think you don't want to build from source, but that's exactly what pip
usually does (and likewise easy_install
), so it's not something to be afraid of.
But all of this is secondary to the main problem: the pycairo
Python module requires the cairo
library (and likewise pixman
), which you don't have. (Actually, depending on your OS X version, you might have a private version that can't be linked externally, or a very old version that's not good enough for pycairo, or no version at all… but any of those three are equivalent as far as you're concerned.)
So you have to get it from somewhere before pycairo
can be built. (And, even if you got a copy built somewhere else, you couldn't use it.)
Contrary to what the docs suggest, I'd use Homebrew rather than MacPorts to install cairo
. MacPorts is designed to build a sort of completely isolated set of tools—so it's great if you want to install cairo
so you can install the MacPorts pycairo
into your MacPorts /opt/local/bin/python
, but it's not so great if you're hoping to get pycairo
built for the stock Apple /usr/bin/python
.