Skip to content Skip to sidebar Skip to footer

Can't Get Pil To Correctly Install On Ubuntu 12.04

I'm using Ubuntu 12.04 and I'm in PIL-hell. I've tried every suggestion I can find online for ways to install PIL, but I have no luck. I know for a fact I have every dependency.

Solution 1:

the simplest way should be the following:

sudo apt-get install python-imaging

if you need to install in a virtualenv, or want the absolute latest version use pip. First install some stuff pil needs, then run the pip install:

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 fresh 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 I run 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--------------------------------------------------------------------

PNG support which you are looking for shows as ok. I suspect that your python installation is probably in some sort of corrupt state. Maybe the symlinking you mentioned or other attempts at installing this package has corrupted your installation. There are three recommendations I can give for correcting this situation

Solutions

  1. re-install ubuntu on the machine. This should definitely work.
  2. create a python virtualenv and then install PIL there using pip. This might work depending on how corrupt the base python system is. The idea here is that virtualenv by default will create a new python environment that only has the standard library in it.
  3. repair your python installation. You could try apt-get purge python-imaging and then re-install the python-imaging package.

Solution 2:

If you are running on Ubuntu 64 bit another step may be needed in addition to Marwan ones:

PIL setup looks for libraries in /usr/lib but Ubuntu 64 places them on /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

Solution 3:

I've experienced problems with PIL and Pillow installed together.

If I install PIL using apt-get install python-imaging and then run selftest.py I get (which is fine):

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

If I then install Pillow through sudo pip install Pillow and then re-run selftest.py 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 solve the multiple "supports not available" and get back to the initial status I just uninstalled Pillow.

Post a Comment for "Can't Get Pil To Correctly Install On Ubuntu 12.04"