2013-05-03 82 views
0


django-simple-captcha无法在我的电脑上显示captcha。
当我运行python manage.py测试验证码,我得到的错误如下:当我运行django-simple-captcha测试时抛出2个错误

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。

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

+0

你安装了正确的版本吗?这可能是因为您的captcha版本不适用于您安装的PIL版本。 – 2013-05-03 19:27:09

+0

我的PIL版本是1.1.7 – user2347948 2013-05-04 14:53:15

回答

4

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

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

pip uninstall PIL 
pip uninstall Pillow 
pip install Pillow 

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

相关问题