Friday, May 13, 2011

Installing PIL with jpeg and freetype support on mac osx with virtualenv, homebrew and pip

When attempting jpeg modifications in python after having done the obvious "pip install PIL", then I get an IOError with the message "encoder jpeg not available" or maybe "decoder jpeg not available".

Because there are so many different ways to install PIL, finding how to fix error on the web is not easy. This post is to help me and others of us who use and enjoy virtualenv, homebrew and pip.

1. Ensure Xcode is installed. Upgrading to OSX 10.7 Lion removes Xcode
2. $ brew install jpeg
3. $ workon {your virtual env} # using virtualenvwrapper
4. if reinstalling: $ pip uninstall PIL
5. $ pip install --no-install PIL

6. edit setup.py in {your virtual env dir}/build/PIL

***setup.py*** - also showing freetype and little cms if needed

7. save and close setup.py
8. pip install PIL