windows下pytesseract识别验证码遇到的WindowsError: [Error 2] 的解决方法
来源:互联网 发布:创意马克杯 知乎 编辑:程序博客网 时间:2024/04/30 23:48
安装PIL+pytesseract
安装很简单,参考http://www.waitalone.cn/python-php-ocr.html
从http://www.lfd.uci.edu/~gohlke/pythonlibs/里面下载pillow选择自己的版本即可, 我是2.7,然而这里有个问题,明明我机子是64位的,我下载了64位的whl然后pip安装的时候居然报错了,说格式不支持,然后我就去下载32位了,居然特么的安装上了。算了....
然后
pip install pytesseract
安装成功后执行脚本:
from PIL import Imagefrom pytesseract import image_to_stringimage = Image.open(r'7364.png') # Open image object using PIL<pre name="code" class="python"><pre name="code" class="plain">报错,错误如下:
Traceback (most recent call last): File "F:/spider/test.py", line 4, in <module> print image_to_string(image) # Run tesseract.exe on image File "C:\Users\tandazhao\spider_venv\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string config=config) File "C:\Users\tandazhao\spider_venv\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract stderr=subprocess.PIPE) File "C:\Python27\Lib\subprocess.py", line 711, in __init__ errread, errwrite) File "C:\Python27\Lib\subprocess.py", line 959, in _execute_child startupinfo)WindowsError: [Error 2]
print image_to_string(image) # Run tesseract.exe on image
上网找解决方法,说是pytesseract.py 里面的
tesseract_cmd = 'tesseract' 改成 tesseract_cmd = 'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'
好,我改
再次运行,嗯,再次报错
Traceback (most recent call last): File "F:/spider/test.py", line 4, in <module> print image_to_string(image) # Run tesseract.exe on image File "C:\Users\tandazhao\spider_venv\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string config=config) File "C:\Users\tandazhao\spider_venv\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract stderr=subprocess.PIPE) File "C:\Python27\Lib\subprocess.py", line 711, in __init__ errread, errwrite) File "C:\Python27\Lib\subprocess.py", line 959, in _execute_child startupinfo)WindowsError: [Error 2]
呵呵哒,仔细看命令,发现windows下\t转义了。。。。然后在tesseract_cmd = 'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'前面加个r,
tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'
执行,OK,识别出来了
C:\Users\tandazhao\spider_venv\Scripts\python.exe F:/spider/test.py
7364
Process finished with exit code 0
哈哈哈
1 0
- windows下pytesseract识别验证码遇到的WindowsError: [Error 2] 的解决方法
- 基于pytesseract的验证码识别
- 基于pytesseract的验证码识别
- pytesseract的简单验证码的识别-python
- python使用pytesseract识别验证码的方法
- pytesseract Windows Error 6错误的解决办法
- python 验证码识别:pytesser .image_file_to_string('1.tif') WindowsError: [Error 2] 解决办法
- python下调用pytesseract识别某网站验证码
- 使用Python机器识别库pytesseract遇到的问题
- 关于Python验证码识别安装PIL、tesseract-ocr与pytesseract模块的错误解决
- Python验证码识别 安装Pillow、tesseract-ocr与pytesseract模块的安装以及错误解决
- Python--pytesseract验证码识别处理实例
- Python模块pytesseract验证码识别
- Python——验证码识别 安装Pillow、tesseract-ocr与pytesseract模块的安装以及错误解决
- pytesseract Windows Error 6
- WindowsError: [Error 32]问题的解决
- 利用python pytesseract进行OCR(验证码识别)
- python 使用tesseract-ocr , pytesseract , PIL进行验证码识别
- 用js在页面上,设置多个按钮,点击当前按钮时,当前按钮文字变为“哈哈”,其他未点击的按钮文字变为“呜呜”。
- UVa OJ 1451 - Average
- iOS开发网络篇—实现一个视频播放客户端小应用(二)
- 利用栈实现二进制转换为八、十、十六进制
- JSP脚本元素、指令元素、动作元素
- windows下pytesseract识别验证码遇到的WindowsError: [Error 2] 的解决方法
- hdu5723 最小生成树 树形dp
- Apache 安全配置方法
- Linux下逻辑地址-线性地址-物理地址图解
- 一个极端的前端国际化方法
- 曲线拟合
- android小技巧
- 全新破解第一季
- Headstrong Student