0


django-simple-captcha 无法在我的计算机上显示验证码。
当我运行 python manage.py test captcha 时,出现以下错误:

python manage.py  test captcha
Creating test database for alias 'default'...
.E...E..........
======================================================================
ERROR: testContentLength (captcha.tests.CaptchaCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/captcha/tests/__init__.py", line 179, in testContentLength
    response = self.client.get(reverse('captcha-image', kwargs=dict(key=key)))
  File "/Library/Python/2.7/site-packages/django/test/client.py", line 453, in get
    response = super(Client, self).get(path, data=data, **extra)
  File "/Library/Python/2.7/site-packages/django/test/client.py", line 279, in get
    return self.request(**r)
  File "/Library/Python/2.7/site-packages/django/test/client.py", line 424, in request
    six.reraise(*exc_info)
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/Library/Python/2.7/site-packages/captcha/views.py", line 80, in captcha_image
    image.save(out, "PNG")
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 1467, in save
    save_handler(self, fp, filename)
  File "/Library/Python/2.7/site-packages/PIL/PngImagePlugin.py", line 605, in _save
    ImageFile._save(im, _idat(fp, chunk), [("zip", (0,0)+im.size, 0, rawmode)])
  File "/Library/Python/2.7/site-packages/PIL/ImageFile.py", line 452, in _save
    e = Image._getencoder(im.mode, e, a, im.encoderconfig)
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 395, in _getencoder
    return encoder(mode, *args + extra)
TypeError: function takes at most 4 arguments (6 given)

======================================================================
ERROR: testImages (captcha.tests.CaptchaCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/captcha/tests/__init__.py", line 30, in testImages
    response = self.client.get(reverse('captcha-image', kwargs=dict(key=key)))
  File "/Library/Python/2.7/site-packages/django/test/client.py", line 453, in get
    response = super(Client, self).get(path, data=data, **extra)
  File "/Library/Python/2.7/site-packages/django/test/client.py", line 279, in get
    return self.request(**r)
  File "/Library/Python/2.7/site-packages/django/test/client.py", line 424, in request
    six.reraise(*exc_info)
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/Library/Python/2.7/site-packages/captcha/views.py", line 80, in captcha_image
    image.save(out, "PNG")
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 1467, in save
    save_handler(self, fp, filename)
  File "/Library/Python/2.7/site-packages/PIL/PngImagePlugin.py", line 605, in _save
    ImageFile._save(im, _idat(fp, chunk), [("zip", (0,0)+im.size, 0, rawmode)])
  File "/Library/Python/2.7/site-packages/PIL/ImageFile.py", line 452, in _save
    e = Image._getencoder(im.mode, e, a, im.encoderconfig)
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 395, in _getencoder
    return encoder(mode, *args + extra)
TypeError: function takes at most 4 arguments (6 given)

----------------------------------------------------------------------
Ran 16 tests in 0.543s

FAILED (errors=2)
Destroying test database for alias 'default'...

我已经安装了 pil。

我不知道在这种情况下发生了什么,请帮忙!谢谢你!

4

1 回答 1

4

当两者都PIL安装Pillow时会发生这种情况。

试试这个命令,它可以帮助我:

pip uninstall PIL
pip uninstall Pillow
pip install Pillow

换句话说,卸载PIL并重新安装Pillow.

于 2013-05-10T16:06:25.920 回答