title: Install PIL with Jpeg support on Ubuntu Oneiric 64bit
link: http://jj.isgeek.net/2011/09/install-pil-with-jpeg-support-on-ubuntu-oneiric-64bits/
author: Jj
description: 
post_id: 779
date: 2011/09/20 16:41:18
created_gmt: 2011/09/20 21:41:18
comment_status: open
slug: install-pil-with-jpeg-support-on-ubuntu-oneiric-64bits

<!--I am posting this because it took me ages to figure out how to solve this one.
<p></p>


<p></p>

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 64bits installation.-->

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](/2011/08/ordered-a-new-laptop/). 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](http://ubuntuforums.org/showpost.php?p=10811107&postcount=5). 

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 ! 

**Update**: 

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

<http://www.sandersnewmedia.com/why/2012/04/16/installing-pil-virtualenv-ubuntu-1204-precise-pangolin/>
    
    
    # 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](http://codeinthehole.com/writing/how-to-install-pil-on-64-bit-ubuntu-1204/)

## Comments

**[Airtonix](#371131 "2011-10-30 19:30:00"):** 

**[Jj](#371132 "2011-10-30 19:32:00"):** I used # to indicate root shell. But yes, it would have been more clear to explicitly use sudo

**[darkpixel](#371153 "2011-12-09 15:18:00"):** Less easy to copy/paste when you put the '#' in front of it... ;)

**[ceolwulf](#371147 "2011-11-29 23:29:00"):** Thanks for the blog post! This was quite annoying.

**[Max M Rasmussen](#371155 "2011-12-14 17:19:00"):** 

**[chris duranti](#371188 "2012-03-26 18:36:00"):** 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](#371174 "2012-02-25 22:05:00"):** Thanks for the blog post Jj!

**[Sebpiq](#371177 "2012-03-05 16:18:00"):** Thanks !!! Saved me quite some time ...

**[darkpixel](#371178 "2012-03-05 18:24:00"):** 

**[Leonardo Vidarte](#371171 "2012-02-11 09:33:00"):** thanks!

**[Emery Clark](#371183 "2012-03-15 14:33:00"):** thanks man, sweet

**[Alan gormley](#371191 "2012-04-14 07:06:00"):** Thanks, you've stopped me banging my head off the desk. Same as Chris, aws did not have support.

**[juanpex](#371194 "2012-05-08 08:58:00"):** also works

**[Alek314](#371202 "2012-06-14 20:12:00"):** GREAT HELP! Thank you amigo!

**[Joshua](#371203 "2012-06-20 10:11:00"):** /usr/lib/i386-linux-gnu/

**[mike waites](#371206 "2012-06-23 04:37:00"):** :( none of these have worked for me :/

**[Mauro Baraldi](#371215 "2012-07-27 21:51:00"):** 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](#371216 "2012-08-01 05:03:00"):** 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](#371213 "2012-07-18 19:21:00"):** Thanks! This is what I needed.

**[Dan Ward](#371220 "2012-09-19 07:38:00"):** ln -s /usr/lib/arm-linux-gnueabi/libz.so /usr/lib/

**[Sef Kloninger](#371219 "2012-09-03 09:21:00"):** Thank you, helpful.

**[mike](#371223 "2012-09-23 08:45:00"):** 

**[Peter Teoh](#371387 "2017-08-09 03:00:55"):** 

