让django-simple-captcha工作

时间:2012-09-05 16:53:47

标签: python django captcha recaptcha

我试图让简单的验证码与我的django一起使用。

完成以下四个步骤后:

我跑了python manage.py test captcha.

它给了我这个:

Traceback (most recent call last):
  File "/Users/cnnlakshmen_2000/Projects/Permissions/captcha/tests/__init__.py", line 26, in testImages
    response = self.client.get(reverse('captcha-image', kwargs=dict(key=key)))
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/test/client.py", line 439, in get
    response = super(Client, self).get(path, data=data, **extra)
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/test/client.py", line 244, in get
    return self.request(**r)
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/Users/cnnlakshmen_2000/Projects/Permissions/captcha/views.py", line 27, in captcha_image
    font = ImageFont.truetype(settings.CAPTCHA_FONT_PATH, settings.CAPTCHA_FONT_SIZE)
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/PIL/ImageFont.py", line 218, in truetype
    return FreeTypeFont(filename, size, index, encoding)
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/PIL/ImageFont.py", line 134, in __init__
    self.font = core.getfont(file, size, index, encoding)
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-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

但实际上我已经安装了pil。

我输入了sudo pip install pil,它给了我这个:

Requirement already satisfied (use --upgrade to upgrade): pil in /Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/PIL
Cleaning up...

不确定我的错误在哪里......需要一些指导...

1 个答案:

答案 0 :(得分:2)

查看_imagingft module not installed

PIL有许多可选的库(FreeType,Jpeg等),如果缺少这些库,那么PIL中的某些功能将无法使用。