编译libjpeg v8,PIL 1.1.7并导入_imaging在系统Python上工作,但在virtualenv中发出此错误:
libjpeg.so.8: cannot open shared object file: No such file or directory
这是在virtualenv
中使用python -v解释器运行的错误>>> import _imaging
dlopen("/home/ygamretuta/dev/py/django/lib/python2.6/site-packages/PIL/_imaging.so", 2);
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libjpeg.so.8: cannot open shared object file: No such file or directory
以下是路径:
/home/ygamretuta/dev/py/django/lib/python2.6/site-packages/distribute-0.6.14-py2.6.egg
/home/ygamretuta/dev/py/django/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg
/home/ygamretuta/dev/py/django/lib/python2.6
/home/ygamretuta/dev/py/django/lib/python2.6/plat-linux2
/home/ygamretuta/dev/py/django/lib/python2.6/lib-tk
/home/ygamretuta/dev/py/django/lib/python2.6/lib-old
/home/ygamretuta/dev/py/django/lib/python2.6/lib-dynload
/usr/lib/python2.6
/usr/lib/python2.6/plat-linux2
/usr/lib/python2.6/lib-tk
/home/ygamretuta/dev/py/django/lib/python2.6/site-packages
/home/ygamretuta/dev/py/django/lib/python2.6/site-packages/PIL
我使用的是Ubuntu 10.10,这是uname-a输出:
Linux ygam-desktop 2.6.35-28-generic #49-Ubuntu SMP Tue Mar 1 14:40:58 UTC 2011 i686 GNU/Linux
我正在使用Python 2.6
我已遵循以下指南:
http://appelfreelance.com/2010/06/libjpeg-pil-snow-leopard-python2-6-_jpeg_resync_to_restart/
http://www.jooncode.com/2010/12/02/python-pil-jpeg-resync-restart-error-imaging-module-solve/
答案 0 :(得分:20)
请在此处查看解释:Why can't Python find shared objects that are in directories in sys.path?
快速解决方法是将包含libjpeg.so.8
的目录添加到/etc/ld.so.conf
文件,然后运行ldconfig
答案 1 :(得分:5)
此外,如果您正在进行本地Python安装,您还可以使用LD_LIBRARY_PATH环境变量控制会话级别的动态链接::
export LD_LIBRARY_PATH=/srv/plone/python/python-2.6/lib
python
import _imaging
...
这样你甚至不会意外地破坏你自己的操作系统。 (它发生了:http://opensourcehacker.com/2011/08/31/zend-server-installation-potentially-kills-your-ssh/)
答案 2 :(得分:0)
从源代码编译库也可以:http://www.ijg.org/files/
如果您使用的是类似Unix的系统,请确保使用jpegsrc.v8.tar.gz。 jpegsr8.zip似乎是MS版本,在构建时会引发所有标准格式问题。