本文介绍了Python:未安装_imagingft C模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了很多在网上发布的解决方案,但它们无效。
I've tried lots of solution that posted on the net, they don't work.
>>> import _imaging
>>> _imaging.__file__
'C:\\python26\\lib\\site-packages\\PIL\\_imaging.pyd'
>>>
因此系统可以找到_imaging但仍然无法使用truetype字体
So the system can find the _imaging but still can't use truetype font
from PIL import Image, ImageDraw, ImageFilter, ImageFont
im = Image.new('RGB', (300,300), 'white')
draw = ImageDraw.Draw(im)
font = ImageFont.truetype('arial.ttf', 14)
draw.text((100,100), 'test text', font = font)
引发此错误:
ImportError: The _imagingft C module is not installed
File "D:\Python26\Lib\site-packages\PIL\ImageFont.py", line 34, in __getattr__
raise ImportError("The _imagingft C module is not installed")
推荐答案
您安装的PIL是在没有libfreetype的情况下编译的。
Your installed PIL was compiled without libfreetype.
您可以获得PIL的预编译安装程序(这里使用libfreetype编译(和许多其他预编译的Python C模块):
You can get precompiled installer of PIL (compiled with libfreetype) here (and many other precompiled Python C Modules):
这篇关于Python:未安装_imagingft C模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!