JPEG, Zlib and Freetype not available for PIL in a virtualenv in Ubuntu

When installing PIL, the Python Imaging Library, in a virtualenv in Ubuntu with pip install PIL, the installer reports that there’s no JPEG, Zlib or Freetype2 support available, even though I had installed all the corresponding packages.

It turns out that the PIL installer looks for the libraries in /usr/lib/ but in Ubuntu they are in /usr/lib/i386-linux-gnu/ or /usr/lib/x86_64-linux-gnu/, depending on the architecture you use.

A quick and dirty solution for this is to create symlinks to those libraries in /usr/lib/, like this: sudo ln -s /usr/lib/i386-linux-gnu/libfreetype.so /usr/lib/ sudo ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib/ sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib/ Or for 64 bits architecture: sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/ sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/ sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/

After this, pip install PIL should work without complaining about lack of these libraries.

You are welcome.

Be the first to know when I post cool stuff

Subscribe to get my latest posts by email.

powered by TinyLetter