Blog

the writings of

Installing PIL with JPEG support on Redhat

April 17, 2014

Installing PIL on Redhat can be a little tricky, particularly if you are trying to do it in a virtualenv

Without virtualenv

if you aren't relying on virtualenv, you should be able to just install PIL using yum:

yum install python-pil

Using virtualenv

If you install PIL (probably using pip) into your virtualenv and it tells you that JPEG support is not available, the problem is likely that redhat installs a 64-bit version of libjpeg and the default PIL installer doesn't know where to find it - as noted in this forum post.

Correcting this is relatively easy, just head to the terminal and follow these steps:

 # Download the latest version of PIL - 1.1.7 at the time of this post
wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz

# Untar
tar xvzf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7

# edit setup file
vim setup.py

Find a line that says: JPEG_ROOT = None

Change it to: JPEG_ROOT = "/usr/lib64"

# save and quite vim, then install from inside the un-tar'd package
pip install ./

That took care of it for me, adding JPEG support - now that it knows where to find the 64-bit JPEG library.

Update:

If the rest of your library support is also failing, you can change the rest of the paths in setup.py to point to lib64 as well:

TCL_ROOT = "/usr/lib64"
JPEG_ROOT = "/usr/lib64"
ZLIB_ROOT = "/usr/lib64"
TIFF_ROOT = "/usr/lib64"
FREETYPE_ROOT = "/usr/lib64"
LCMS_ROOT = "/usr/lib64"
blog comments powered by Disqus