We build our Python webservices in a virtualenv with all external packages stored locally. This gives us reproducible results on a variety of Linux distros, Mac, and Windows, both for developer machines and production boxes.
I am quite unable to get JPEG and PNG support working in the Python Imaging Library. Here's a repro case in a clean virtual machine.
Code:
$ sudo apt-get install python-virtualenv
$ virtualenv --no-site-packages ~/venv
$ source ~/venv/bin/activate
$ mkdir -p ~/PIL ~/temp/site-packages
$ export PYTHONPATH=~/temp/site-packages/
$ cd ~/PIL
$ wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
$ sudo apt-get build-dep python-imaging
# sets up zlib1g-dev, libfreetype6-dev, libjpeg62-dev, liblcms1-dev, ...
$ easy_install -v --install-dir ~/temp/site-packages --find-links ~/PIL\
--allow-hosts=None --always-unzip Imaging
...
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2]
--------------------------------------------------------------------
--- TKINTER support available
*** JPEG support not available
*** ZLIB (PNG/ZIP) support not available
*** FREETYPE2 support not available
--- LITTLECMS support available
--------------------------------------------------------------------
$ identify basketball.png flowers.jpg logo.gif
basketball.png PNG 340x340 340x340+0+0 8-bit DirectClass 157KB 0.000u 0:00.000
flowers.jpg[1] JPEG 500x333 500x333+0+0 8-bit DirectClass 66.5KB 0.020u 0:00.019
logo.gif[2] GIF 276x110 276x110+0+0 8-bit PseudoClass 256c 8.56KB 0.000u 0:00.000
$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
>>> img = Image.open('basketball.png')
>>> img.load()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/georger/temp/site-packages/PIL-1.1.7-py2.7-linux-i686.egg/ImageFile.py", line 189, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "/home/georger/temp/site-packages/PIL-1.1.7-py2.7-linux-i686.egg/Image.py", line 385, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder zip not available
>>> img = Image.open('flowers.jpg')
>>> img.load()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/georger/temp/site-packages/PIL-1.1.7-py2.7-linux-i686.egg/ImageFile.py", line 189, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "/home/georger/temp/site-packages/PIL-1.1.7-py2.7-linux-i686.egg/Image.py", line 385, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available
Ideas?
Bookmarks