我通过执行build,build_ext -i和install在带有Python 2.7的CentOS 6.2上构建并安装了PIL。我必须更改库路径,以便提供所有支持。
当我运行selftest.py时,它说一切正常,并且提供了所有支持(尤其是JPEG)。

运行打开jpeg,添加内容并保存的程序时,出现错误:

  File "/opt/python2.7.2/lib/python2.7/site-packages/PIL/Image.py", line 401, in _getencoder
    raise IOError("encoder %s not available" % encoder_name)
IOError: encoder jpeg not available


我的程序在其他系统上也可以正常运行,当我将其更改为png时,它可以在centOS计算机上正常运行。我使用python2.7运行了所有命令,并且已经尝试重新安装PIL。

简而言之:在安装PIL之前,它可以在自检中成功运行,但是在安装后,它不再起作用。

最佳答案

我在ubuntu forums中找到了解决方案

1/ Call 'pip install -I pil --no-install' to download and unpack the PIL source into your
build directory;
2/ Get into your build directory and edit setup.py;
3/ Find the line that says 'add_directory(library_dirs, "/usr/lib")' (line 214 here);
4/ Add the line 'add_directory(library_dirs, "/usr/lib/i386-linux-gnu")' afterwards;
5/ Call 'pip install -I pil --no-download' to finish the installation.

关于centos - 在CentOS自测下可以进行PIL安装,但jpeg无法正常工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8762418/

10-11 22:33
查看更多