2011-10-04 80 views
25

我使用Ubuntu和VitualEnv作为我的Django项目。pip install PIL -E票据-1 - 没有JPEG/PNG支持

我有使用新立得包管理器安装PIL库,它工作正常。但是,当我创建一个VitrualEnv并尝试使用PIP它installes安装PIL,但我得到这个奇怪的现象:

-------------------------------------------------------------------- 
PIL 1.1.7 SETUP SUMMARY 
-------------------------------------------------------------------- 
version  1.1.7 
platform  linux2 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
       [GCC 4.5.2] 
-------------------------------------------------------------------- 
*** TKINTER support not available 
*** JPEG support not available 
*** ZLIB (PNG/ZIP) support not available 
*** FREETYPE2 support not available 
*** LITTLECMS 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. 

我希望我可以用requirements.txt为我所有的依赖关系,但可能是PIL有以某种方式手动安装...但如何?

编辑:谢谢约翰·凯斯,你是对的,我跑:

sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/ 
sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/ 
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/ 

又经过尝试PIL安装我得到:

-------------------------------------------------------------------- 
PIL 1.1.7 SETUP SUMMARY 
-------------------------------------------------------------------- 
version  1.1.7 
platform  linux2 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
       [GCC 4.5.2] 
-------------------------------------------------------------------- 
*** TKINTER support not available 
--- JPEG support available 
--- ZLIB (PNG/ZIP) support available 
--- FREETYPE2 support available 
*** LITTLECMS 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. 

编辑:您可能需要安装libfreetype6-dev libjpeg8-dev

编辑:另一个不错的选择是使用Pillow而不是PIL

回答

4

似乎对我们来说(PIL 1.7.7)的解决方案是首先卸载PIL,然后卸载Pillow,然后使用pip安装pillow --upgrade。当然你需要安装libjpeg8-dev。

+2

谢谢,我尝试了很多东西,但是这是唯一修复它的东西! – deweydb

+0

认为这可能是有用的:http://pythonadventures.wordpress.com/2013/05/19/problems-with-pil-use-pillow-instead/ – user2290820

+0

使用Pillow是一个好的解决方案。 – x4snowman

5

和公正的情况下,如果你正在使用的virtualenv,你不必需要建立全系统的符号链接,这里是通用的变通方法,在任何架构的工作原理:

ln -s /usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`/libz.so $VIRTUAL_ENV/lib/ 
ln -s /usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`/libfreetype.so $VIRTUAL_ENV/lib/ 
ln -s /usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`/libjpeg.so $VIRTUAL_ENV/lib/ 

而你需要要在virtualenv激活的shell会话中执行这些行,符号链接将在您的virtualenv lib目录中创建。

命令dpkg-architecture -qDEB_HOST_MULTIARCH正用于检测主系统库目录(uname -i不可靠)。而环境变量$VIRTUAL_ENV由virtualenv activate脚本设置。