Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. I've tried all of the symlink methods. I've modified the setup.py file to ensure it finds the correct directories. I've also tried building from source and installing through pip. Nothing works. Here's what I get when I install:

--------------------------------------------------------------------
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's 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...

like image 687
user1209675 Avatar asked Nov 22 '12 03:11

user1209675


3 Answers

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.
like image 113
Marwan Alsabbagh Avatar answered Nov 10 '22 11:11

Marwan Alsabbagh


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
like image 22
flaviodesousa Avatar answered Nov 10 '22 10:11

flaviodesousa


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.

like image 22
Caumons Avatar answered Nov 10 '22 11:11

Caumons