1.安裝依賴包
1.1 ubuntu安裝
apt-get install python-dev
apt-get install libjpeg-dev apt-get install libjpeg8-dev apt-get install libpng3 apt-get install libfreetype6-dev ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib
或者python
sudo apt-get build-dep python-imaging
因爲ubuntu14中libfreetype 的頭文件在/usr/include/freetype2目錄下,但PIL中使用的路徑是freetype,因此須要作如下操做
cd /usr/include ln -s freetype2 freetype
1.2 redhat/centos
yum install python-devel libjpeg-turbo-devel libpng-devel freetype-devel
最後使用pip安裝PIL pip install PIL --allow-unverified PIL --allow-all-externallinux
安裝完成後能夠看到以下版本信息,能夠看到PNG中支持JPEG/PNG/ZIP/FREETYPE2
ubuntu
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.5 (default, Sep 15 2014, 17:30:20)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------centos