解决virtualenv下安装Python PIL的support not available问题 !本文可能 超过1年没有更新,今后内容也许不会被维护或者支持,部分内容可能具有时效性,涉及技术细节或者软件使用方面,本人不保证相应的兼容和可操作性。 配置的Debian Web服务器,通过virtualenv构建了Pyramid项目,大部分代码运行挺正常,到一个验证码程序时出错了,检查日志得到如下Python异常: ImportError: No module named PIL 但是我PIL明明是通过easy_install直接安装的啊,求助于网络找到了这么一篇解决方案《The problem with installing PIL using virtualenv or buildout》,原文的意思是在pypi上的PIL版本不兼容于setuptools,所以不能被easy_install正常安装,必须指定url安装兼容版本,比如如下命令:
经过这么一折腾,确实测试下来 ImportError: The _imagingft C module is not installed 搜索了网络,大多是编译安装PIL时,系统缺少库文件导致的,通过下面的命令安装可能的包或者库文件:
然后重新编译下载PIL,结果在这过程中提示如下警告: -------------------------------------------------------------------- *** TKINTER support not available (Tcl/Tk 8.4 libraries needed) *** JPEG support not available *** ZLIB (PNG/ZIP) support not available *** FREETYPE2 support not available -------------------------------------------------------------------- To add a missing option, make sure you have the required library, and set the corresponding ROOT variable in the setup.py script. 所有的必须的库仍然提示support not available,说明刚才的安装预先库的办法是没有用的,纠结了。 搜索了网络,大多是针对Ubuntu的解决方案,不过功夫不负有心人,还是让我找到了Debian下的解决办法《PIL zip jpeg decoders not working on runtime but work on install/selftest》,现在分享出来: 其实最简单的办法就是先用命令
好了,卸载先前的官方PIL,安装Pillow后,所有问题都解决了! |
|