PERENNIAL FASCINATION WITH ALL THINGS TECH

Main menu

Post navigation

How To Install PIL On Ubuntu

Let’s say you want to play around with images in Python. To do that, we need a Python package that can handle all the image manipulation. Python Imaging Library (PIL) is one of most popular libraries that is used to process the image data. Actually, people use Pillow now, which is a modern repackaged version of PIL. It has a lot of nice functionalities and it works well. Let’s see how you can install PIL on 64-bit Ubuntu 12.04.

Once you install these packages, we have to symlink the three image libraries into /usr/lib. Wait, now what is “symlink”? A symlink, which is short for symbolic link, is a special type of file that contains a reference to another file or directory. The reference is in the form of an absolute or relative path and it affects path-name resolution. To do that, type in the following commands on the terminal:

PIL (or Pillow) should now install with support for JPEGs, PNGs and FreeType, as indicated by the compilation output:

--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.3 (default, Apr 19 2014, 18:10:34)
[GCC 4.6.3]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------

I see some errors. What do I do?

Here is the solution to some of the common problems you might face.

Missing image libraries: If the image libraries are not installed and available in /usr/lib, you’ll see something like this:

--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.3 (default, Apr 19 2014, 18:10:34)
[GCC 4.6.3]
--------------------------------------------------------------------
*** TKINTER support not available
*** JPEG support not available
*** ZLIB (PNG/ZIP) support not available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------

To add a missing option, make sure you have the required library, and set the corresponding ROOT variable in the setup.py script.

Missing python headers: Make sure you have python-dev. Without it, you’ll see something that ends with the following:

2 thoughts on “How To Install PIL On Ubuntu”

Thanks a lot for your article, that was very helpfull for a python newbie like me, because PIP and Pillow are painfull to be correctly installed on a Linux system – both Python 2.x and 3.X- (and libfreetype a bit too … 🙂 )

BTW, are you sure your command lines are complete ? I mean the simlinks : in your command line, both symlinks are linked to /usr/lib, and I wonder how the mentionned libraries wil be found at runtime, since their names are not complete ? (maybe I misunderstood something … )

The directory ‘/home/kunal/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
The directory ‘/home/kunal/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
Collecting pil
Could not find a version that satisfies the requirement pil (from versions: )
No matching distribution found for pil
***************************************************************************************************
SHOWING THIS ERROR