解決數字驗證碼及運行錯誤
阿新 • • 發佈:2017-12-19
conf body found box mage this true 使用 clas
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為什麽會報錯,總之,這樣修改後可以正常運行了
解決數字驗證碼及運行錯誤