5

像这样的脚本:

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

导致此 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

如何为我的 PIL 获得 jpeg 支持?这个问题似乎是众所周知的,但现有的线程并没有为我解决这个问题。我将 brew 和 pip 用于我的 python 包,并且已经尝试了以下方法:

  • brew install jpeg 原因Error: jpeg-8d already installed
  • brew install libjpeg原因Error: jpeg-8d already installed
  • sudo pip install Pillow- 安装工作但没有改变任何东西

如何为我的 PIL 安装获得 jpeg 支持?有任何想法吗?

4

3 回答 3

8

我不明白为什么,但重新安装 PIL 解决了这个问题:

sudo pip uninstall pil
sudo pip install pil
于 2012-08-05T22:44:21.483 回答
0

对于登陆这里的非 OSX 人员,我发现链接到我的 64 位 Ubuntu 系统上的 64 位库以修复编译问题。

于 2013-04-15T21:20:10.377 回答
0

我在 Ubuntu 12.04 64 位上遇到了类似的问题,并通过符号链接 PIL 正在寻找的库/usr/lib(它实际上正在寻找它们)来解决它:

# 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
于 2013-01-29T23:39:00.337 回答