python PIL ImportError: The _imagingft C module is not installed

python 阅读:861
# import _imaging : No module named _imaging


# 需要先安装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库

wget http://effbot.org/downloads/Imaging-1.1.6.tar.gz
tar -zxvf Imaging-1.1.6.tar.gz
cd 
Imaging-1.1.6
rm -rf build


# 设置JPEG库的路径

vim setup.py :
JPEG_ROOT = libinclude("/usr/local")
python setup.py build
python setup.py install


# 把JPEG加入到系统库路径

echo '/usr/local/lib' >> /etc/ld.so.conf
ldconfig


# OK,完成

上述操作完成后就不会再报找不到 _imaging 的错误了。

别高兴太高,如果用到了freetype2,还会报_imagingft找不到。解决办法类似,先安装freetype2,在安装PIL里指定freetype2路径,将freetype2加到系统库路径中即可。