机器是win7 64,python版本是python 2.7(32) 好像win7 32,xp 32都没出现这个问题
方法一:
方法二:
在 PIL官网 给出的链接 http://effbot.org/downloads/#pil 下了个 PIL-1.1.7.win32-py2.7.exe
安装后执行 from PIL import ImageFont font = ImageFont.truetype("DejaVuSans.ttf",25)
报错 The _imagingft C module is not installed
直接import _imagingft,报配置不正确
看来得自己手动编译 PIL了
先到官网上下载这个
http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
在sourceforge上下载freetype
http://iweb.dl.sourceforge.net/project/freetype/freetype2/2.4.6/freetype-2.4.6.tar.bz2
解压freetype,进freetype-2.4.6\builds\win32\vc2008这个目录,打开freetype.sln
编译,选择lib release
目录freetype-2.4.6\objs\win32\vc2008下会生成一个freetype246MT.lib
更改其名字,叫freetype.lib
把这个lib放到freetype-2.4.6\include目录下
解压Imaging-1.1.7
Imaging-1.1.7,freetype-2.4.6两个在同一目录下
编辑Imaging-1.1.7\setup.py 把 FREETYPE_ROOT = None 这句改为 FREETYPE_ROOT = '../freetype-2.4.6/include'
执行python setup.py build_ext -i
出现:Unable to find vcvarsall.bat 错误
编译出一个_imagingft,将C:\Python27\Lib\site-packages\PIL_imagingft.pyd替换为编译出来的