I’m working on installing Mezzanine, a CMS written in Django, for a project I’m working on. Mezzanine requires Pillow, an imaging library for Python. Pillow requires/recommends a number of libraries. It took me a little bit to figure out how to get (mostly) everything working on Debian 8.2 (Jessie). Here’s a command to install all of Pillow’s requirements in one fell swoop:

sudo aptitude install libjpeg62-turbo-dev libopenjpeg-dev libfreetype6-dev libtiff5-dev liblcms2-dev libwebp-dev tk8.6-dev

When I run pip install -v pillow, I see this in the output:

version  Pillow 3.0.0
platform linux 3.4.2 (default, Oct  8 2014, 10:45:20)
 [GCC 4.9.1]
*** TKINTER support not 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 available
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.

Unfortunately, it doesn’t seem like Pillow recognizes TCL/TK (despite the fact that I installed tk8.6-dev, which includes tcl8.6-dev), so I can’t get Tkinter support working. I also installed OpenJPEG via libopenjpeg-dev, but the version in Debian seems to be too old:

$ aptitude show libopenjpeg-dev
Package: libopenjpeg-dev                 
State: installed
Automatically installed: no
Multi-Arch: same
Version: 1:1.5.2-3
Priority: extra
Section: libdevel
Maintainer: Debian PhotoTools Maintainers <pkg-phototools-devel@lists.alioth.debian.org>
Architecture: amd64
Uncompressed Size: 111 k
Depends: libopenjpeg5 (= 1:1.5.2-3)
Description: development files for OpenJPEG, a JPEG 2000 image library - dev
 OpenJPEG is a library for handling the JPEG 2000 image compression format. JPEG 2000 is a wavelet-based image compression standard and permits progressive transmission by pixel and resolution accuracy for progressive downloads of an encoded image. It supports lossless and lossy compression, supports higher compression than JPEG 1991, and has resilience to
 errors in the image. 
 This is the development package
Homepage: http://www.openjpeg.org

Tags: devel::library, role::devel-lib

The Pillow docs state that version 2.0.0 and 2.1.0 are supported, so 1.5.2-3 must be too old.

If someone knows how to get Tkinter or OpenJPEG working, please let me know in the comments! I don’t think it’ll matter much in the end, but it’d be nice to have all of Pillow’s functionality available.

UPDATE: I was able to get Tkinter working with the help of the Pillow devs. Issue #1473 has the full discussion, but the main takeaway is that I had to install python3-tk, which enables Tkinter support.

Additionally, the Pillow docs actually contain a Building on Linux section that I missed before. It more or less echoes what I lay out in this blog post. This is the final command I had to use:

sudo aptitude install libjpeg62-turbo-dev libopenjpeg-dev libfreetype6-dev libtiff5-dev liblcms2-dev libwebp-dev tk8.6-dev python3-tk

Unfortunately, OpenJPEG still isn’t supported, but that’s just because Pillow requires a newer version than is contained in the Debian repos; build it from source if you need it, and you should be good to go.