码迷,mamicode.com
首页 > 编程语言 > 详细

python获取图片验证码

时间:2018-03-05 21:16:41      阅读:463      评论:0      收藏:0      [点我收藏+]

标签:output   init   报错   exce   return   ISE   import   oserror   out   

一、安装linux下图片处理工具:

# which tesseract
/usr/bin/tesseract

二、安装python连接模块:

pip install pytesseract

pip install Pillow

三、进入python运行环境:

1报错:

File "/usr/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 194, in image_to_string
return run_and_get_output(image, ‘txt‘, lang, config, nice)
File "/usr/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 141, in run_and_get_output
run_tesseract(**kwargs)
File "/usr/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 112, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

 

修改源码:

vim /usr/lib/python2.7/site-packages/pytesseract/pytesseract.py

修改为绝对路径:(

tesseract_cmd = ‘/usr/bin/tesseract‘

>>> import pytesseract
>>> from PIL import Image
>>> image = Image.open(‘/tmp/cap.jpg‘)
>>> vcode = pytesseract.image_to_string(image)

>>> print(vcode)
blZgb

python获取图片验证码

标签:output   init   报错   exce   return   ISE   import   oserror   out   

原文地址:https://www.cnblogs.com/songge1209/p/8511338.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!