Unable to get PIL for proper installation on Ubuntu 12.04

I am using Ubuntu 12.04 and I am in PIL-hell. I tried every suggestion that I can find on the Internet for ways to install PIL, but I had no luck. I know that I have every kind of addiction. I tried all symlink methods. I modified the setup.py file to make sure it finds the correct directories. I also tried to build the source and install via pip. Nothing works. Here is what I get when installing:

-------------------------------------------------------------------- PIL 1.1.7 SETUP SUMMARY -------------------------------------------------------------------- version 1.1.7 platform linux2 2.7.3 (default, Nov 4 2012, 15:42:19) [GCC 4.4.3] -------------------------------------------------------------------- *** TKINTER support not available --- JPEG support available --- ZLIB (PNG/ZIP) support available --- FREETYPE2 support available *** LITTLECMS support not available -------------------------------------------------------------------- 

Here is what selftest.py shows:

 -------------------------------------------------------------------- PIL 1.1.7 TEST SUMMARY -------------------------------------------------------------------- Python modules loaded from ./PIL Binary modules loaded from ./PIL -------------------------------------------------------------------- --- PIL CORE support ok *** TKINTER support not installed *** JPEG support not installed *** ZLIB (PNG/ZIP) support not installed *** FREETYPE2 support not installed *** LITTLECMS support not installed -------------------------------------------------------------------- 

I have no idea what else to try. I'm just trying to play with some stupid PNG files ...

+6
source share
4 answers

The simplest way should be the following:

 sudo apt-get install python-imaging 

if you need to install in virtualenv or want to use the absolute latest version. Install some pilot needs first, and then run pip installation:

 sudo apt-get install libjpeg-dev libjpeg62 libjpeg62-dev zlib1g-dev libfreetype6 libfreetype6-dev pip install PIL 

To respond to the comment below. If you take a new installation of ubuntu 12.04 and run apt-get install python-imaging , you will have PIL installed correctly on your system. on my ubuntu 12.04 box when running selftest.py I get the following output:

 -------------------------------------------------------------------- PIL 1.1.7 TEST SUMMARY -------------------------------------------------------------------- Python modules loaded from /usr/lib/python2.7/dist-packages/PIL Binary modules loaded from /usr/lib/python2.7/dist-packages/PIL -------------------------------------------------------------------- --- PIL CORE support ok *** TKINTER support not installed --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok --- LITTLECMS support ok -------------------------------------------------------------------- 

The PNG support you are looking for shows how good it is. I suspect your python installation is probably in some kind of damaged state. Perhaps your link or other attempts to install this package ruined your installation. There are three recommendations I can give to correct this situation.

Solutions

  • reinstall ubuntu on the machine. This should definitely work.
  • create python virtualenv and then set the PIL there using pip. This may work depending on how corrupt the underlying python system is. The idea here is that virtualenv will by default create a new python environment in which there is only a standard library.
  • restore your installation on python. You can try apt-get purge python-imaging and then reinstall the python image package.
+9
source

If you are running 64-bit Ubuntu, you may need to take another step in addition to Marwan:

The PIL setting looks for libraries in /usr/lib , but Ubuntu 64 puts them in /usr/lib/x86_64-linux-gnu . A working solution is to create links:

 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 sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib 
+4
source

I had problems with the PIL and Pillow installed together .

If I install PIL with apt-get install python-imaging and then run selftest.py , I will get (this is normal):

 --- PIL CORE support ok *** TKINTER support not installed --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok --- LITTLECMS support ok 

If I installed Pillow via sudo pip install Pillow and then run selftest.py again, I get:

 --- PIL CORE support ok *** TKINTER support not available (Tcl/Tk 8.5 libraries needed) --- JPEG support available --- ZLIB (PNG/ZIP) support available *** TIFF G3/G4 (experimental) support not available *** FREETYPE2 support not available *** LITTLECMS support not available *** WEBP support not available 

In order to resolve several "unavailable supports" and return to their original state, I simply uninstalled Pillow.

+1
source

Python PIL for Linux

  • install python-dev

sudo apt-get install python-dev

  1. install pil now

sudo pip install PIL

-1
source

All Articles