python – PIL不会导入_imaging C模块:“***未安装_imaging C模块”
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python – PIL不会导入_imaging C模块:“***未安装_imaging C模块”,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3065字,纯文字阅读大概需要5分钟。
内容图文
![python – PIL不会导入_imaging C模块:“***未安装_imaging C模块”](/upload/InfoBanner/zyjiaocheng/821/7bd2023b371b44af987b8675996c6574.jpg)
来自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
--------------------------------------------------------------------
这是在Ubuntu 9.04上安装的.
我只需要PIL来启用Django上传和调整各种图像(不同格式)的大小.不幸的是,它目前无法处理JPEG.在执行PIL的selftest.py之后,它想出了这个:
*** The _imaging C module is not installed
我尝试使用python -v解释器导入Image和_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是问题所在.我做了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.]
解决方法:
似乎在我安装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
虽然我还没有完全回答原来的问题,但我找到了另一种解决方案,并希望上述信息能够在这种情况下帮助其他人!
内容总结
以上是互联网集市为您收集整理的python – PIL不会导入_imaging C模块:“***未安装_imaging C模块”全部内容,希望文章能够帮你解决python – PIL不会导入_imaging C模块:“***未安装_imaging C模块”所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。