Building PIL with Freetype2 on Snow Leopard
7 July 2011
I had some trouble getting the venerable Python Imaging Library (PIL) compiled with the Freetype feature on Mac OS X 10.6. Doing a simple
pip install or
easy_install will build it with just the basic options. But if you need to generate Captchas and the like (with django-simple-captcha, for example) you'll need the Freetype option, too.
In fact, OS X comes with Freetype2 installed (as part of the X11 package), just not in a location the PIL build script knows about. That is simple to fix, however:
$ cd ~/Downloads $ curl -LO http://effbot.org/downloads/Imaging-1.1.7.tar.gz $ tar -zxf Imaging-1.1.7.tar.gz $ cd Imaging-1.1.7 $ echo 'FREETYPE_ROOT = "/usr/X11/lib", "/usr/X11/include"' > setup_site.py $ python setup.py build
The setup summary printed out at the end of the build should now say “FREETYPE2 support available”, which would mean this procedure worked as designed.
Alex Clark says:
9 July 2011
Alternatively, you can easy_install Pillow (PIL fork that has X11 paths in setup.py)
Dean Powell says:
21 November 2011
I wanted to thank you for your suggestion on installing 'Pillow' instead of just installing 'PIL'.
I just ran this command:
$ pip install Pillow
And it worked great.
28 March 2012
Works perfectly! I did have trouble at first insofar as "import _imaging" would fail, but I tracked that down to a problem with libjpeg so I re-built libjpeg using gcc-4.0, re-installed PIL, and it's all working like a charm now. Thanks! Nash