用pil产生验证码呈现:ImportError: The _imagingft C module i
添加时间:2013-7-31 点击量:
这个是因为PIL没有编译freetype导致的
查看 lib/python2.7/site-packages/PIL/
看看 _imagingft.so 是否存在
# 须要先安装jpeg库
wget http://www.ijg.org/files/jpegsrc.v7.tar.gz
tar -zxvf jpegsrc.v7.tar.gz
cd jpeg-7
CC=gcc -arch x86_64
./configure --enable-shared --enable-static
make
make install
# 然后再安装PIL库
让PIL支撑freetype的办法
1、安装freetype开辟库
yum install freetype-devel
2、源代码http://effbot.org/downloads/Imaging-1.1.7.tar.gz
3、批改setup.py文件
批改
JPEG_ROOT = libinclude(/usr/local)
FREETYPE_ROOT = /usr/lib64,/usr/include/freetype2/freetype
4、查看支撑项
python setup.py build_ext -i
--- FREETYPE2 support available 重视这一项
5、编译安装
python setup.py install
若上方的设置都失败,则只能拿出下面的杀手锏:
sudo apt-get build-dep python-imaging
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/
pip install -U PIL
当现下面的提示时,则申明安装成功了:
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.3 (default, Apr 10 2012, 22:21:37)
[GCC 4.6.3]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
LITTLECMS support not available
--------------------------------------------------------------------
这个是因为PIL没有编译freetype导致的
查看 lib/python2.7/site-packages/PIL/
看看 _imagingft.so 是否存在
# 须要先安装jpeg库
wget http://www.ijg.org/files/jpegsrc.v7.tar.gz
tar -zxvf jpegsrc.v7.tar.gz
cd jpeg-7
CC=gcc -arch x86_64
./configure --enable-shared --enable-static
make
make install
# 然后再安装PIL库
让PIL支撑freetype的办法
1、安装freetype开辟库
yum install freetype-devel
2、源代码http://effbot.org/downloads/Imaging-1.1.7.tar.gz
3、批改setup.py文件
批改
JPEG_ROOT = libinclude(/usr/local)
FREETYPE_ROOT = /usr/lib64,/usr/include/freetype2/freetype
4、查看支撑项
python setup.py build_ext -i
--- FREETYPE2 support available 重视这一项
5、编译安装
python setup.py install
若上方的设置都失败,则只能拿出下面的杀手锏:
sudo apt-get build-dep python-imaging
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/
pip install -U PIL
当现下面的提示时,则申明安装成功了:
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.3 (default, Apr 10 2012, 22:21:37)
[GCC 4.6.3]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
LITTLECMS support not available
--------------------------------------------------------------------