使用ubuntu 13.10,python 2.7.5:
>>> import _imaging, Image >>> from PIL import Image, ImageDraw, ImageFilter, ImageFont >>> im = Image.new('RGB', (300,300), 'white') >>> draw = ImageDraw.Draw(im) >>> font = ImageFont.truetype('arial.ttf', 14) Traceback (most recent call last): File "", line 1, in 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) File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFont.py", line 34, in __getattr__ raise ImportError("The _imagingft C module is not installed") **ImportError: The _imagingft C module is not installed** >>>
那么为什么会这样呢?我该如何解决?我按照以下说明在本主题的底部找到了:
pip uninstall PIL apt-get install libjpeg-dev apt-get install libfreetype6-dev apt-get install zlib1g-dev apt-get install libpng12-dev pip install PIL --upgrade
但在升级PIL时,看看我看到的内容:
-------------------------------------------------------------------- PIL 1.1.7 SETUP SUMMARY -------------------------------------------------------------------- version 1.1.7 platform linux2 2.7.5+ (default, Sep 19 2013, 13:48:49) [GCC 4.8.1] -------------------------------------------------------------------- *** TKINTER support not available *** JPEG support not available *** ZLIB (PNG/ZIP) support not available *** FREETYPE2 support not available *** LITTLECMS support not available --------------------------------------------------------------------
这是正常对所有这些项目的支持不是可用?我该如何解决这个问题?
PIL
基本上死了,叉子Pillow
真的是你应该使用的.你需要通过它导入它
from PIL import Image, ...
它维护了所有功能PIL
,并增加了很多功能,包括Python 3兼容性.此外,它正在积极开发中,与之不同PIL
,因此您发现的任何错误实际上都有可能得到修复 - 与功能请求相同.
您可以PIL
通过运行来安装它(卸载后)
pip install Pillow
我相信Ubuntu有一个软件包,但我的VM目前让我头疼,我无法检查......