2010-11-06 78 views
4

背景从PIL setup.py建立一个位:PIL不会导入_imaging C模块中:“***的_imaging C模块中未安装”

-------------------------------------------------------------------- 
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 
-------------------------------------------------------------------- 

这是的Ubuntu 9.04安装。

我只需要PIL就可以让Django上传和调整各种不同格式的图像。不幸的是,它目前不能处理JPEG。执行PIL的selftest.py后,想出了这个:

*** The _imaging C module is not installed 

我试图导入图像,并使用Python解释器-v(两者合作)_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是可用的,但由于某种原因没有被进口在其他情况正常。

我一直在寻找这个问题的解决方案,在过去的几个小时,并没有任何接近找到一个。我错过了一些愚蠢明显的东西吗?或者有什么想法,为什么它不工作?

在此先感谢!

另外:我知道http://effbot.org/zone/pil-imaging-not-installed.htm,但只是演示错误,并没有提供解决方案。

编辑:我一直在窥探,看来导入_imagingmath是问题。我做了蟒蛇-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.] 

回答

5

看来,在我安装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 

虽然我还没有完全回答了原来的问题,我已经找到一个替代的解决方案,并希望上述信息将能够帮助任何人在这种情况下,其他人!

0

您尚未安装的libjpeg库。这样做:

sudo apt-get install libjpeg 

并重新运行PIL安装。

+0

这给我的错误:“E:找不到包的libjpeg”。我确实已经安装了libjpeg62 - 是否相当于? – 2010-11-06 13:03:45

+0

你有libjpeg62-devel吗? – 2010-11-06 13:25:16

+0

不,我有libjpeg62和libjpeg62-dev。 – 2010-11-06 13:31:05

2

我解决了这个问题通过安装的libjpeg发展:

sudo apt-get install libjpeg8-dev 

然后完全重新安装PIL模块。

(我使用的是一个虚拟的环境,但它应该工作一样好运行Python作为标准)

相关问题