pip install PIL -E TICKETS-1 – No JPEG/PNG support

Question:

I’m using Ubuntu and VitualEnv for my Django project.

I have PIL library installed using Synaptic Package Manager and it is working fine. But when I create an VitrualEnv and try to install PIL using pip it installes but I get this strange behaviour:

--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      linux2 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
              [GCC 4.5.2]
--------------------------------------------------------------------
*** TKINTER support not available
*** JPEG support not available
*** ZLIB (PNG/ZIP) support not available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.

I was hoping that I can use requirements.txt for all my dependencies, but may be PIL have to be somehow manually installed … but how?

Edit: Thank you John Keyes, you are right, I run:

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

and after another try for PIL install I get:

--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      linux2 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
              [GCC 4.5.2]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
-    -------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.

Edit: You may need to install libfreetype6-dev libjpeg8-dev

Edit: Another good option is to use Pillow instead of PIL

Asked By: Julian Popov

||

Answers:

This thread on ubuntu forums covers this topic.

Answered By: John Keyes

A solution that seems to work for us (as of PIL 1.7.7) is to uninstall PIL first and then Pillow and then pip install pillow –upgrade. Of course you need to have libjpeg8-dev installed.

Answered By: jMyles

And just in case, if you are using virtualenv, you don’t need to need to create system-wide symlinks, here is the universal workaround that works on any architecture:

ln -s /usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`/libz.so $VIRTUAL_ENV/lib/
ln -s /usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`/libfreetype.so $VIRTUAL_ENV/lib/
ln -s /usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`/libjpeg.so $VIRTUAL_ENV/lib/

And you need to execute these line inside virtualenv activated shell session, symlinks will be created inside your virtualenv lib directory.

Command dpkg-architecture -qDEB_HOST_MULTIARCH is being used to detect main system libs directory (uname -i is not reliable). And environment variable $VIRTUAL_ENV is set by virtualenv activate script.

Answered By: Sergey Stolyarov