https://digi.bib.uni-mannheim.de/tesseract/
tesseract-orc下载
在使用 pytesseract中的image_to_string时报错如下:
Python3.5版本,已经正确安装了Pillow和pytesseract模块,安装方法请百度,使用PyCharm也可以管理,比较简单
Traceback (most recent call last):
File "D:/PycharmProjects/net.bjxueche/CoreImage.py", line 82, in <module>
text = image_to_string(image=image, boxes=True)
File "D:\mysoft\Python\Python35\lib\site-packages\pytesseract\pytesseract.py", line 162, in image_to_string
config=config)
File "D:\mysoft\Python\Python35\lib\site-packages\pytesseract\pytesseract.py", line 95, in run_tesseract
stderr=subprocess.PIPE)
File "D:\mysoft\Python\Python35\lib\subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "D:\mysoft\Python\Python35\lib\subprocess.py", line 1220, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
解决办法:
打开文件 pytesseract.py,找到如下代码,将tesseract_cmd的值修改为全路径,在此使用就不会报错了。
# CHANGE THIS IF TESSERACT IS NOT IN YOUR PATH, OR IS NAMED DIFFERENTLY
# tesseract_cmd = ‘tesseract‘
tesseract_cmd = ‘C:/Program Files (x86)/Tesseract-OCR/tesseract.exe‘
- 1
- 2
- 3
PS:我的环境变量中明明有这个值,在CMD中也可以正常使用“tesseract”命令,不知道pytesseract为什么会报错,总之,这样修改后可以正常运行了