PIL安装

来源:互联网 发布:html中如何加入js语句 编辑:程序博客网 时间:2024/05/07 20:42
no modual named PIL
PIL安装
首先要先安装Python(在这里不做介绍)。

安装完Python后,安装PIL库就非常简单了,只需按如下步骤进行

1、下载PIL的Source Kit(因为这个包支持全部平台) Imaging--1.1.6.tar.gz
   URL:  http://www.pythonware.com/products/pil/index.htm

2、解压缩包 tar -zxvf Imaging-1.1.6.tar.gz

3、进入到解压后的目录 cd Imaging-1.1.6

4、Build pakage: python setup.py build_ext -i
        这这步遇到Python.h: No such file or directory错误,具体看附A
--5、测试;  python selftest.py
         我测试有问题,但是安装没有问题
6、安装 python setup.py install

执行完上述操作后,可以直接在程序用使用 import Image进行使用PIL中的Image类


附A:
Python.h: No such file or directory
安装python开发包
找包
yum search python |grep dev
装包
yum -y install python-devel.x86_64
记得还得安装gcc  yum -y install gcc




解决使用PIL “decoder jpeg not available”错误

http://www.360doc.com/content/13/0314/15/7972_271475405.shtml
 


yum install libjpeg-devel
yum install freetype-devel
安装之后:
[root@192 Imaging-1.1.7]#  python setup.py build_ext -i
running build_ext
building '_imagingft' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/freetype2 -IlibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.6 -c _imagingft.c -o build/temp.linux-x86_64-2.6/_imagingft.o
gcc -pthread -shared build/temp.linux-x86_64-2.6/_imagingft.o -L/usr/local/lib -L/usr/lib -L/usr/lib64/ -L/usr/lib64 -lfreetype -lpython2.6 -o /opt/python_install/Imaging-1.1.7/PIL/_imagingft.so
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      linux2 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
              [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]
--------------------------------------------------------------------
*** 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.

To check the build, run the selftest.py script.
[root@192 Imaging-1.1.7]# 
0 0