Question

I'm sure there's a duplicate of this somewhere out there but I looked and am about at the end of my rope. I'm trying get PIL working on my mac OS X 10.8 so that I can use dev_appserver.py to test an imaging feature. First I had trouble installing PIL until I got Homebrew and installed it using brew install pil. I was under the opinion that brew installed all the necessary dependencies but when I tried to resize a jpeg in my app, it says IOError: decoder jpeg is not available. So I looked online and most places said I needed to (1) uninstall PIL, (2) install libjpeg from source and (3) reinstall PIL. So, I brew uninstall PIL, and then

curl -O www.ijg.org/files/jpegsrc.v7.tar.gz
tar zxvf jpegsrc.v7.tar.gz
cd jpeg-7d/
./configure
make
make install

and finally brew install pil. I restart dev_appserver.py and reload the page on localhost, but same error. I tested pil out from the python command-line with

>>> from PIL.Image import Image
>>> f = open("someimagefile", "rb")
>>> i = Image()
>>> i.fromstring(f.read(), decoder_name="jpeg")
Traceback blah blah blah
IOError: decoder jpeg not available

I don't have much experience installing utilities from command-line, so I probably missed something obvious. Again, sorry if there are duplicates, but like I said, I looked and couldn't find anything that seemed to work.

Was it helpful?

Solution 2

PIL did not found libjpeg headers during compilation. Consult your build system documentation on how to specify headers ("includes") location, eg. as environment variables.

OTHER TIPS

Finally got it working! Thanks to @zgoda and this link. Here are the steps I ended up with for those of you who have the same problem:

First make sure PIL is not installed. Download libjpeg from http://www.ijg.org/files/jpegsrc.v8c.tar.gz, unpacked it, ./configure, and make. When I tried to make install it couldn't find the directory to store the man pages so installation failed. I looked at the information on the above link and decided to

cp -r ~/Downloads/jpeg-6d/ /usr/local/jpeg

I suspect if the installation goes fine than that line isn't necessary.

Then edit the following line in PIL's setup.py:

JPEG_ROOT = None

to

JPEG_ROOT = "/usr/local/jpeg"

finally:

$ python setup.py build
$ python setup.py install
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top