我从pil官网下的Imaging文件夹安装的
还要安装freetype 以得到对
ImageFont的支持
import ImageFont
然后在运行的时候出现
File "/home/lyc_test/handlers/VerificationCode.py", line 23, in createImg
font = ImageFont.truetype('ARIAL.ttf', 36)
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFont.py", line 218, in truetype
return FreeTypeFont(filename, size, index, encoding)
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFont.py", line 134, in __init__
self.font = core.getfont(file, size, index, encoding)
IOError: cannot open resource
错误
是因为
ARIAL.ttf字体文件找不到
需要提供系统的绝对路径 /usr/share/fonts/ARIAL.TTF
大小写不能错!!!!扩展名大小写都要区分