【问题标题】:Tell sage where to find libjpeg告诉 sage 在哪里可以找到 libjpeg
【发布时间】:2011-09-30 02:08:16
【问题描述】:

我在 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,看起来 jpeg 包已经安装。我还在 /opt/local/lib 中找到了 libjpeg。我尝试在 sage 脚本中和在 Sage 中使用 os 库操作 LD_LIBRARY_PATH,但无法摆脱此错误。我在网上搜索了如何让PIL找到libjpeg,但我发现涉及修改setup.py重建PIL。 sage 似乎没有包含 PIL 的 setup.py。

有其他人遇到过这个问题并解决了吗?也许有人熟悉 PIL?

【问题讨论】:

    标签: python jpeg python-imaging-library sage


    【解决方案1】:

    答案是重新安装 PIL。

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

    就这么简单,只花了一分钟。在我的机器上重新安装它可能允许它在我的机器上找到库的位置。

    【讨论】:

      猜你喜欢
      • 2012-07-31
      • 2018-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多