当我运行django-simple-captcha test throw 2错误时

时间:2013-05-03 18:33:00

标签: python django captcha


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。

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

1 个答案:

答案 0 :(得分:4)

安装PILPillow时会发生这种情况。

尝试此命令,它可以帮助我:

pip uninstall PIL
pip uninstall Pillow
pip install Pillow

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