2011-10-04 77 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腳本設置。