Jj Del Carpio

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 !

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

Comments

#371131" title="2011-10-30 19:30:00">Airtonix:

#371132" title="2011-10-30 19:32:00">Jj: I used # to indicate root shell. But yes, it would have been more clear to explicitly use sudo

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

#371147" title="2011-11-29 23:29:00">ceolwulf: Thanks for the blog post! This was quite annoying.

#371155" title="2011-12-14 17:19:00">Max M Rasmussen:

#371188" title="2012-03-26 18:36:00">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...

#371174" title="2012-02-25 22:05:00">bigcatmm: Thanks for the blog post Jj!

#371177" title="2012-03-05 16:18:00">Sebpiq: Thanks !!! Saved me quite some time ...

#371178" title="2012-03-05 18:24:00">darkpixel:

#371171" title="2012-02-11 09:33:00">Leonardo Vidarte: thanks!

#371183" title="2012-03-15 14:33:00">Emery Clark: thanks man, sweet

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

#371194" title="2012-05-08 08:58:00">juanpex: also works

#371202" title="2012-06-14 20:12:00">Alek314: GREAT HELP! Thank you amigo!

#371203" title="2012-06-20 10:11:00">Joshua: /usr/lib/i386-linux-gnu/

#371206" title="2012-06-23 04:37:00">mike waites: :( none of these have worked for me :/

#371215" title="2012-07-27 21:51:00">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!! =(

#371216" title="2012-08-01 05:03:00">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.

#371213" title="2012-07-18 19:21:00">Andrew Badr: Thanks! This is what I needed.

#371220" title="2012-09-19 07:38:00">Dan Ward: ln -s /usr/lib/arm-linux-gnueabi/libz.so /usr/lib/

#371219" title="2012-09-03 09:21:00">Sef Kloninger: Thank you, helpful.

#371223" title="2012-09-23 08:45:00">mike:

#371387" title="2017-08-09 03:00:55">Peter Teoh:

Jj Avatar of Jj

Reply or react to this post via Webmentions