[virtualenv, PIL, CentOSx64]virtualenv使用PIL报错: decoder jpeg not available

2013-11-20 14:38:46 +08:00
 geew
搜索了好多了.
好多的解决方案都试过了, 没有用.

系统自带的python的话没有这个错误, 所以我想是不是相关的依赖库的问题, 但是尝试了
ln -s /usr/lib64/libjpeg.so /usr/lib
ln -s /usr/lib64/libjpeg.so /usr/local/lib
等做链接的方式, 都没起到作用.

后来看到这个: http://hi.baidu.com/liheng_2009/item/bf67bb2088dc120672863e98
测试机上按照这个更改了setup.py里面的路径, build_ext -i的时候还是没问题, 但安装到virtualenv里面发现问题依旧, 然后我的解决方案是用build在当前目录产生的PIL文件夹把virtualenv里面python site-packages文件夹里面的PIL直接覆盖了. 然后PIL就可以正常使用了......

但是生产机发现这个方法没用, 然后我用的python2.6 site-package里面的PIL覆盖2.7中的PIL文件夹, 然后重装PIL, 然后莫名其妙的好了....

为啥啊?个人觉得这些个解决方案不好, 谁晓得以后会不会出别的问题, stackoverflow上的方案基本也试过了, 没起作用啊...求教万能的v友们了.
2988 次点击
所在节点    问与答
3 条回复
geew
2013-11-20 14:41:59 +08:00
错误的单元测试结果如下:

[root@xxx Imaging-1.1.7]# python selftest.py
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from /usr/local/lib/python2.7/site-packages/PIL
Binary modules loaded from /usr/local/lib/python2.7/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok
*** TKINTER support not installed
*** JPEG support not installed
*** ZLIB (PNG/ZIP) support not installed
*** FREETYPE2 support not installed
*** LITTLECMS support not installed
--------------------------------------------------------------------
Running selftest:
*****************************************************************
Failure in example:
try:
_info(Image.open(os.path.join(ROOT, "Images/lena.jpg")))
except IOError, v:
print v
from line #24 of selftest.testimage
Expected: ('JPEG', 'RGB', (128, 128))
Got: decoder jpeg not available
1 items had failures:
1 of 57 in selftest.testimage
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.
geew
2013-11-20 14:44:13 +08:00
同一个机子上, 2.6的结果是对的, 所以应该不是缺少什么库的问题, 应该是库的加载的问题...但2.7会加载哪里的库?驱动?模块?

2.6执行结果:

[root@xxx Imaging-1.1.7]# /usr/bin/python selftest.py
--------------------------------------------------------------------
PIL 1.1.6 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from /usr/lib64/python2.6/site-packages/PIL
Binary modules loaded from /usr/lib64/python2.6/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok
*** TKINTER support not installed
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok
*** LITTLECMS support not installed
--------------------------------------------------------------------
Running selftest:
--- 57 tests passed.
geew
2013-11-20 17:11:46 +08:00
在stackoverflow整理了各种资料, 有谁遇到这个问题的话去看看吧:
http://stackoverflow.com/questions/18504835/pil-decoder-jpeg-not-available-on-ubuntu-x64/20091508#20091508

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/89921

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX