来自PIL setup.py构建的一些背景信息:
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
[GCC 4.3.3]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------这是在Ubuntu9.04上安装的。
我只需要PIL使Django能够上传和调整各种图像(不同格式)的大小。不幸的是,它目前无法处理JPEG。在执行了PIL的selftest.py之后,它想到了以下内容:
*** The _imaging C module is not installed我尝试使用python解释器导入图像和_imaging (这两者都有效).
>>> from PIL import Image
import PIL # directory PIL
# PIL/__init__.pyc matches PIL/__init__.py
import PIL # precompiled from PIL/__init__.pyc
# PIL/Image.pyc matches PIL/Image.py
import PIL.Image # precompiled from PIL/Image.pyc持续了很长一段时间
>>> import _imaging
dlopen("/usr/local/lib/python2.6/dist-packages/PIL/_imaging.so", 2);
import _imaging # dynamically loaded from /usr/local/lib/python2.6/dist-packages/PIL/_imaging.so因此,在使用python解释器时,_imaging是可用的,但由于某些原因,在其他情况下没有正确导入。
在过去的几个小时里,我一直在寻找解决这个问题的方法,但是还没有找到一个解决方案。我是不是漏掉了一些愚蠢的显而易见的东西?或者,对于为什么它不起作用有任何想法吗?
提前感谢!
另外:我知道,但这只是演示了错误,没有提供解决方案。
编辑:,我一直在窥探,似乎导入_imagingmath是问题所在。我使用python -vv selftest.py来查看它的崩溃位置,这就是它是如何发生的:
dlopen("/usr/local/lib/python2.6/dist-packages/PIL/_imagingmath.so", 2);
import _imagingmath # dynamically loaded from /usr/local/lib/python2.6/dist-packages/PIL/_imagingmath.so
*** The _imaging C module is not installed
# clear __builtin__._
[etc. etc. etc.]发布于 2010-11-08 13:06:44
在我安装PIL之前,我似乎没有安装libjpeg。因此,我安装了libjpeg-62和libjpeg62-dev,然后重新安装了PIL。同样的错误发生了。
*** The _imaging C module is not installed我在另一个网站上找到了一个潜在的解决方案,建议我从源代码中强制重建PIL:
sudo python setup.py build_ext -f这会产生一些关于这个错误的有趣信息(如果你也有这个问题的话)。gcc似乎没有正确地编译各种文件(我有gcc4.3.3),即:
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
libImaging/Quant.c: In function 'rehash_collide':
libImaging/Quant.c:154: warning: cast to pointer from integer of different size(其他一切似乎都很好)
我对此和其他一些网站做了一些研究,认为这是因为我用来构建PIL的gcc版本与我正在使用的构建python.org Python的版本不同。这很有道理。Here's the other question I found that suggests this。
最后,我尝试了最后一次安装,但这次是从存储库安装的,而不是我下载的tar。这似乎解决了这个问题。
sudo apt-get install python-imaging虽然我没有完全回答原来的问题,但我找到了另一个解决方案,并希望上面的信息能够帮助其他任何人在这种情况下!
发布于 2011-09-09 11:45:50
我通过安装libjpeg开发来修复这个问题:
sudo apt-get install libjpeg8-dev然后重新安装PIL模块。
(我使用的是一个虚拟环境,但它的运行应该与标准运行Python一样好)
发布于 2010-11-06 12:48:00
您还没有安装libjpeg库。这样做:
sudo apt-get install libjpeg重新运行PIL安装程序。
https://stackoverflow.com/questions/4113095
复制相似问题