我正在尝试在我的django应用中使用Django-simple-captcha http://django-simple-captcha.readthedocs.org/en/latest/usage.html。但验证码图像未显示在模板中。当我在浏览器中查看源代码时出现以下错误。我仔细地跟踪了文档,并且已经同步了所有内容。
Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/captcha/views.py" in captcha_image
46. font = ImageFont.truetype(settings.CAPTCHA_FONT_PATH, settings.CAPTCHA_FONT_SIZE * scale)
File "/Library/Python/2.7/site-packages/PIL/ImageFont.py" in truetype
228. return FreeTypeFont(font, size, index, encoding)
File "/Library/Python/2.7/site-packages/PIL/ImageFont.py" in __init__
131. self.font = core.getfont(font, size, index, encoding)
File "/Library/Python/2.7/site-packages/PIL/ImageFont.py" in __getattr__
42. raise ImportError("The _imagingft C module is not installed")
Exception Type: ImportError at /captcha/image/f02c7bf84cd31c4caf8d6b2f8931a01689902c83/
Exception Value: The _imagingft C module is not installed
我知道之前已经多次询问过这个问题,我已经阅读了几个stackoverflow的答案,但我仍然对行动过程感到困惑。
我在我的OSX Mavericks上安装了Pillow。
答案 0 :(得分:1)
我通过在运行pip install Pillow
之前安装freetype和freetype2 devel包解决了上述错误。
在SuSE Linux上工作。
答案 1 :(得分:0)
在ubuntu 14.04中为我工作:
pip uninstall pil
或(取决于您使用的是什么)
pip uninstall pillow
然后
sudo apt-get update
apt-get install libfreetype6-dev libxft-dev libjpeg62 libjpeg-devel
在输出中,确保安装完成
并且终极
pip install pil
或
pip install pillow