告诉圣人在哪里找到libjpeg

时间:2011-09-30 02:08:16

标签: python jpeg python-imaging-library sage

我在Mac OS X上安装了Sage。看起来它有PIL。以下代码给出了一个IOError ..

import Image
a = Image.open("pic.jpg")
a.thumbnail((int(100), int(100)))

这是我得到的错误。

IOError                                   Traceback (most recent call last)

<ipython console> in <module>()

/sage/local/lib/python2.6/site-packages/PIL/Image.pyc in thumbnail(self, size, resample)
   1520         self.draft(None, size)
   1521 
-> 1522         self.load()
   1523 
   1524         try:

/sage/local/lib/python2.6/site-packages/PIL/ImageFile.pyc in load(self)
    178 
    179             for d, e, o, a in self.tile:
--> 180                 d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
    181                 seek(o)
    182                 try:

/sage/local/lib/python2.6/site-packages/PIL/Image.pyc in _getdecoder(mode, decoder_name, args, extra)
    373         return apply(decoder, (mode,) + args + extra)
    374     except AttributeError:
--> 375         raise IOError("decoder %s not available" % decoder_name)
    376 
    377 def _getencoder(mode, encoder_name, args, extra=()):

IOError: decoder jpeg not available

对我来说,似乎找不到libjpeg。我在我的机器上检查了MacPorts,&amp;看起来已经安装了jpeg包。我还在/ opt / local / lib中找到了libjpeg。我尝试在sage脚本和放大器中操纵LD_LIBRARY_PATH。而在Sage中,使用os库,却未能摆脱这个错误。我在互联网上搜索了如何让PIL找到libjpeg,但我发现的是修改setup.py重建PIL。 sage似乎不包括PIL的setup.py。

是否有其他人遇到此问题&amp;解决了吗?也许有人熟悉w / PIL?

1 个答案:

答案 0 :(得分:2)

答案是重新安装PIL。

sage.misc.package.install_package("pil", force=True)

就是那么简单&amp;它花了一分钟。在我的机器上重新安装它可能允许它在我的机器上找到库的位置。

相关问题