[Image-SIG] Getting PIL to work on OSX Snow Leopard

Simon Mosk-Aoyama simonsez at gmail.com
Sat Jun 5 01:29:26 CEST 2010


Hi All-


I posted last week about a problem I was having, and Fredrick was kind
enough to point me in the right direction towards fixing
my problem, but unfortunately I spent the better part of today failing to
get PIL to work on my OSX Snow Leopard box, so I thought
before I abandon my attempts to get this to work I'd post again here.

I initially tried to install both libjpeg and PIL via Darwin Ports, but
unfortunately when reading a JPG I would get the following error:
broken data stream when reading image file

I then tried to install PIL via source but I received a mismatch error where
PIL was looking for version libjpeg 62 while Port had installed
version 8.0.

So I went back and installed libjpeg 6b from source using the instructions I
found on this blog post:
http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/

tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config/config.sub .
cp /usr/share/libtool/config/config.guess .
./configure --enable-shared --enable-static
make
sudo make install


This seemed successful as the files seem to have installed fine:

simon@/Users/simon/: ls -al /usr/local/lib/*jpeg*
-rw-r--r--  1 root  wheel  201336 Jun  4 15:56 /usr/local/lib/libjpeg.a
-rwxr-xr-x  1 root  wheel     433 Jun  4 15:56 /usr/local/lib/libjpeg.la


I then downloaded PIL 1.1.7 and edited setup.py to have JPEG_ROOT =
libinclude("/usr/local") and ran:
python setup.py build_ext -i

and got:

running build_ext
--- using frameworks at /System/Library/Frameworks
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      darwin 2.6.5 (r265:79063, Apr 17 2010, 18:49:39)
              [GCC 4.2.1 (Apple Inc. build 5659)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
--- LITTLECMS support available
--------------------------------------------------------------------
To check the build, run the selftest.py script.

Running the selftest:

simon@/Users/simon/: python selftest.py
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from ./PIL
--------------------------------------------------------------------
--- PIL CORE support ok
--- TKINTER support ok
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok
--- LITTLECMS support ok
--------------------------------------------------------------------
Running selftest:
*****************************************************************
Failure in example:
try:
 _info(Image.open(os.path.join(ROOT, "Images/lena.jpg")))
except IOError, v:
 print v
from line #24 of selftest.testimage
Expected: ('JPEG', 'RGB', (128, 128))
Got: broken data stream when reading image file
1 items had failures:
   1 of  57 in selftest.testimage
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.

Checking to ensure the file I built is being executed I run:

simon@/Users/simon/source/sls_scrapers/Imaging-1.1.7: python
Python 2.6.5 (r265:79063, Apr 17 2010, 18:49:39)
[GCC 4.2.1 (Apple Inc. build 5659)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.insert(0, '.')
>>> from PIL import Image
>>> Image.core
<module 'PIL._imaging' from './PIL/_imaging.so'>
>>> image = Image.open('images/lena.jpg')
>>> image
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=128x128 at
0x100774CB0>
>>> image.load()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./PIL/ImageFile.py", line 215, in load
    raise_ioerror(e)
  File "./PIL/ImageFile.py", line 52, in raise_ioerror
    raise IOError(message + " when reading image file")
IOError: broken data stream when reading image file

I'm at a bit of a standstill now as I can't figure out what else to do -
I've seemingly re-built libjpeg correctly from source and
have re-built PIL to point at this newly built libjpeg, but it's still
failing.

Does anyone else have any idea how to solve this?

thanks!

-simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20100604/0475efae/attachment-0001.html>


More information about the Image-SIG mailing list