0

我正在尝试在我的 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。

4

2 回答 2

1

我通过在运行前安装 freetype 和 freetype2 开发包解决了上述错误pip install Pillow

在 SuSE Linux 上工作。

于 2015-01-26T11:01:43.990 回答
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
于 2015-04-16T17:08:15.553 回答