1.确保安装PIL所需的系统库
yum -y install zlib
yum -y install zlib-devel
yum -y install libjpeg
yum -y install libjpeg-devel
yum -y install freetype
yum -y install freetype-devel
2.下载Imaging-1.1.7.tar.gz并解压
3.安装
cd Imaging-1.1.7
python setup.py build_ext -i
确保
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY -------------------------------------------------------------------- version 1.1.7 platform linux2 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] -------------------------------------------------------------------- *** TKINTER support not available --- JPEG support available --- ZLIB (PNG/ZIP) support available --- FREETYPE2 support available *** LITTLECMS support not available --------------------------------------------------------------------
4.修改setup.py
TCL_ROOT = "/usr/lib64/"
JPEG_ROOT = "/usr/lib64/"
ZLIB_ROOT = "/usr/lib64/"
TIFF_ROOT = "/usr/lib64/"
FREETYPE_ROOT = "/usr/lib64/"
LCMS_ROOT = "/usr/lib64/"
5.install
python setup.py install
过程中会出现调用gcc进行编译的过程,如果没有这个过程,基本上就有问题。
6.如果之前安装有问题则需要删除PIL
cd /opt/Python-2.7/lib/python2.7/site-packages
rm -rf PIL
rm -rf PIL.pth