Installing PIL / Pillow on Debian / Ubuntu

2014-07-03 | #python, #solution, #ubuntu

This article is mostly identical to the one about Filer not generating thumbnails, but for better discoverability, here's the condensed text again, specifically for PIL/Pillow installation:

1. Make sure you installed all needed libraries beforehand:

sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev \

libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk

2. If you want to install PIL/Pillow via easy_install or pip (which I recommend):

sudo apt-get install python-dev python-setuptools

3. On newer Debians/Ubuntus you mighty need to symlink some libs:

Newer Debians/Ubuntus don't seem to find the libs, so you might have to symlink them:

ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so

ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/libfreetype.so

ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/libz.so

Newer Debians/Ubuntus only search for freetype and not the current freetype2, so symlink this as well:

cd /usr/include/

ln -s freetype2 freetype

4. Install PIL/Pillow

pip install PIL

pip install Pillow

5. If PIL cannot be found:

pip install PIL --allow-external PIL --allow-unverified PIL

6. The correct output after installation:

--------------------------------------------------------------------

PIL SETUP SUMMARY

--------------------------------------------------------------------

version Pillow 2.4.0

platform linux2 2.7.3 (default, Feb 27 2014, 20:00:17)

[GCC 4.6.3]

--------------------------------------------------------------------

--- TKINTER support available

--- JPEG support available

*** OPENJPEG (JPEG2000) support not available

--- ZLIB (PNG/ZIP) support available

--- LIBTIFF support available

--- FREETYPE2 support available

--- LITTLECMS2 support available

--- WEBP support available

*** WEBPMUX support not available

--------------------------------------------------------------------

PIL's summary is a little shorter but should at least contain JPEG, FREETYPE2 and PNG as supported.

7. If weird errors arise:

You might try to sudo the pip installs.