我已经尝试了很多在网上发布的解决方案,它们不起作用.
>>> import _imaging
>>> _imaging.__file__
'C:\\python26\\lib\\site-packages\\PIL\\_imaging.pyd'
>>>
Run Code Online (Sandbox Code Playgroud)
所以系统可以找到_imaging但仍然不能使用truetype字体
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)
Run Code Online (Sandbox Code Playgroud)
引发此错误:
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")
Run Code Online (Sandbox Code Playgroud)