geew
V2EX  ›  问与答

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

By geew at 2013 年 11 月 20 日 · 3656 次点击
搜索了好多了.
好多的解决方案都试过了, 没有用.

系统自带的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友们了.
3 条回复  •  1970-01-01 08:00:00 +08:00
geew
   1
geew  
OP
   2013 年 11 月 20 日
错误的单元测试结果如下:

[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
   2
geew  
OP
   2013 年 11 月 20 日
同一个机子上, 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
   3
geew  
OP
   2013 年 11 月 20 日
在stackoverflow整理了各种资料, 有谁遇到这个问题的话去看看吧:
http://stackoverflow.com/questions/18504835/pil-decoder-jpeg-not-available-on-ubuntu-x64/20091508#20091508
© 2026 V2EX · 30ms · 3.9.8.5