PIL does not recognize jpeg library under Mac OS

Scripts:

from PIL import Image, ImageOps
img = Image.open('1.JPG')
thumb = ImageOps.fit(img, (200,200) , Image.ANTIALIAS, (0.5, 0.5))

raise this IOError:

Traceback (most recent call last):
  (...)
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 385, in _getdecoder
    raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available

How do I get jpeg support for my PIL? This problem seems to be well known, but existing threads do not solve it for me. I am using brew and pip for my python packages and have already tried the following:

  • brew install jpeg causes Error: jpeg-8d already installed
  • brew install libjpeg causes Error: jpeg-8d already installed
  • sudo pip install Pillow - the installation works, but does not change anything

How do I get jpeg support for my PIL installation? Any ideas?

+5
source share
3 answers

I don't understand why, but reinstalling PIL fixed the problem:

sudo pip uninstall pil
sudo pip install pil
+8
source

I ran into a similar problem on the 64-bit version of Ubuntu 12.04 and solved it by referencing the libraries that PIL was looking for in /usr/lib(where he was really looking for them):

# symlink image libraries so PIL can find them
ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
# etc for any other libraries
0

OSX, , 64- 64- Ubuntu, .

0

All Articles