The problem with installing PIL using virtualenv or buildout

The PIL version packaged on pypi (by the author) is incompatible with setuptools and thus not easy_installable. People have created easy_installable versions elsewhere. Currently, you need to specify a find-links URL and use pip get a good package:

pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL

By using pip install with the --no-index you avoid running the risk of finding the PyPI (non-fixed) original of PIL. If you were to use easy_install, you must use a direct link to the source tarball of a corrected version; easy_install stubbornly still uses the PyPI link over the find-links URL:

easy_install http://dist.plone.org/thirdparty/PIL-1.1.7.tar.gz

To include PIL in a buildout, either specify the egg with the same version pin or use a versions section:

[buildout]
parts =
find-links =
    http://dist.plone.org/thirdparty/
eggs =
    PIL
versions = versions

[versions]
PIL = 1.1.7

Edit March 2011: Fixes to address the packaging issues have been merged into PIL's development tree now, so this workaround may soon be obsolete.

Edit February 2013: Just use Pillow and be done with it. :-) Clearly waiting for the original package to be fixed has not paid off.


Use Pillow: the "friendly" PIL fork :-) It offers:

  • Full setuptools compatibility
  • Faster release cycle
  • No image code changes that differ from PIL (i.e. it aims to track all PIL image code changes, and make none of its own changes without reporting them upstream.)
  • Windows binaries

If PIL ever does exactly what Pillow does, then the fork will die. Until that happens, we have Pillow.

DISCLAIMER: I am the fork author, and Pillow was created mainly to make my job easier (although it's great to see other folks using it too).

EDIT: Pillow 2.0.0 was released on March 15, 2013. It offers Python 3 support and many bug fixes/enhancements. While we still attempt to track changes with upstream PIL, (unfortunately or fortunately depending on how you look at it) Pillow has begun to drift away from PIL.


For Ubuntu I found I needed to to install the C headers package for my python version (2.7)

sudo apt-get install python2.7-dev

Afterwards, pip install pil worked.


On Windows, I installed PIL in a virtualenv as follows:

Install PIL in your global python site-packages by executing the .exe from: http://www.pythonware.com/products/pil/

Then, as a "do it yourself-er", copy the PIL.pth file and PIL directory in C:\Python25\Lib\site-packages to your virtualenv site-packages directory. Yeah, python is still a "get your hands dirty" environment...