[bug] captcha中demo執行失敗(TypeError must be sequence of length 4, not 2)

LinJM-機器視覺發表於2016-08-26

安裝了驗證碼輸出的python包,可以根據官方demo提示,執行如下程式碼:

from captcha.image import ImageCaptcha
captcha_producer = ImageCaptcha()
img = captcha_producer.generate("1234")

卻報瞭如下的Error資訊:
img = captcha_producer.generate(“1234”)
File “/usr/local/lib/python2.7/dist-packages/captcha/image.py”, line 40, in generate
im = self.generate_image(chars)
File “/usr/local/lib/python2.7/dist-packages/captcha/image.py”, line 220, in generate_image
self.create_noise_curve(im, color)
File “/usr/local/lib/python2.7/dist-packages/captcha/image.py”, line 132, in create_noise_curve
Draw(image).arc(points, start, end, fill=color)
File “/usr/lib/python2.7/dist-packages/PIL/ImageDraw.py”, line 164, in arc
self.draw.draw_arc(xy, start, end, ink)
TypeError: must be sequence of length 4, not 2

解決方案:
更新PIL的版本。我本機的PIL版本號是1.1.7.
這裡寫圖片描述

版本過低,需要更新到最新的版本:

sudo pip install Pillow --upgrade

線上現在太慢了,這裡提供一個離線版本:http://download.csdn.net/detail/linoi/9613654

通過

sudo pip install /home/jeremy/Pillow-3.3.0.tar.gz

安裝。

相關文章