Installing PIL into a virtualenv properly in Ubuntu

Python Imaging Library (PIL) is notorious for giving installation problems.

On a fresh install of Ubuntu (12.04) if you

pip install pil

You will see a lot of compiling and a message that reads:

Successfully installed pil
Cleaning up…

Seems all went well? Not really, if you look up you will also see

——————————————————————–
*** TKINTER support not available
*** JPEG support not available
*** ZLIB (PNG/ZIP) support not available
*** FREETYPE2 support not available
*** LITTLECMS support not available
——————————————————————–

Support not available for all the items??? wtf?
Lets fix this for JPEG, ZLIB and FREETYPE2.

Open Synaptic Package Manager and find and check the following items.

  • libjpeg8
  • libjpeg8-dev
  • libfreetype6
  • libfreetype6-dev
  • zlib1g
  • zlib1g-dev

Apply and install all the selected packages.

Now comes the dirty work. We have to go and symlink a few files. Im on Ubuntu 32bit.

Type these commands into your terminal:

sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib/
sudo ln -s /usr/lib/i386-linux-gnu/libfreetype.so /usr/lib/
sudo ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib/

If you use 64bit then you type these instead

sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/
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/

Now we can uninstall pil, push y to confirm the uninstallation. Finally let us install pil again.

pip install pil

and now you see

——————————————————————–
*** TKINTER support not available
— JPEG support available
— ZLIB (PNG/ZIP) support available
— FREETYPE2 support available
*** LITTLECMS support not available
——————————————————————–

Support available! Great success. High Five!

About these ads

One thought on “Installing PIL into a virtualenv properly in Ubuntu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s