Jj's web stream

Install PIL with Jpeg support on Ubuntu Oneiric 64bit

I am posting this because it took me ages to figure out how to solve this one.

I could not get PIL to compile with JPEG, Zlib or freetype support on my virtualenv. I am using Ubuntu Oneiric Beta1 on a Lenovo Thinkpad X220. That is a 64bit installation.

As read in every blog post out there, you first need to install the system libraries so PIL can find them.

$ sudo apt-get install libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev

After that, your regular pip install PIL should work under most situations. In my case I was still seeing this summary after the installation:

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

After a lot of googling around, I found this solution on Ubuntu forums.

It turns out that the APT installations put the libraries under **/usr/lib/x86_64-linux-gnu** and PIL will search for them in **/usr/lib/**. So you have to create symlinks for PIL to see them.

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

Now proceed and reinstal PiL, pip install -U PIL:

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

tada :D !


I just had this issue again on Ubuntu Precise, I found a solution here:


# ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
# ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
# ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/

Note the uname -i that prints the box's arquitecture. This is a much more generic solution!

How to do it on Ubuntu Precise Pagolin 12.04



Jj: I used # to indicate root shell. But yes, it would have been more clear to explicitly use sudo

darkpixel: Less easy to copy/paste when you put the '#' in front of it... ;)

ceolwulf: Thanks for the blog post! This was quite annoying.

Max M Rasmussen:

chris duranti: Thanks so much! Django kept crashing, but only on production. This did the trick, apparently there was no jpeg/png support on ec2 but my computer ships with it. Oops...

bigcatmm: Thanks for the blog post Jj!

Sebpiq: Thanks !!! Saved me quite some time ...


Leonardo Vidarte: thanks!

Emery Clark: thanks man, sweet

Alan gormley: Thanks, you've stopped me banging my head off the desk. Same as Chris, aws did not have support.

juanpex: also works

Alek314: GREAT HELP! Thank you amigo!

Joshua: /usr/lib/i386-linux-gnu/

mike waites: :( none of these have worked for me :/

Mauro Baraldi: Well, have installed i386 version, and seems to be ok http://pastebin.com/a762sHGy. BUT, when I try to open a jpeg image with ImageTk http://pastebin.com/kdCcm6yg. Give up!! =(

Lalo Martins: linking to /usr/lib is a dangerous bad idea; it will break mysteriously when you update your system. Better to link to $VIRTUAL_ENV/lib.

Andrew Badr: Thanks! This is what I needed.

Dan Ward: ln -s /usr/lib/arm-linux-gnueabi/libz.so /usr/lib/

Sef Kloninger: Thank you, helpful.


Peter Teoh: