我试图将pytesseract用于OCR。
我已安装google tesseract 3.03
我安装了pytesseract 0.1.6
我正在运行Python 3.5.1
我正在运行Windows 8
Tesseract也在我的路径中(我可以在正常CMD的任何地方调用它,它将返回帮助功能)
这是我尝试执行的代码:
try:
import Image
except ImportError:
from PIL import Image
import pytesseract
im=Image.open('C:/Users/NeusAap/Google Drive/School/Jaar 1/Periode 1/Programming/Miniproject/GarageProject/scripts/test.png')
print(pytesseract.image_to_string(im))
但它会返回此错误:
Traceback (most recent call last):
File "C:/Users/NeusAap/Google Drive/School/Jaar 1/Periode 1/Programming/Miniproject/GarageProject/scripts/main.py", line 8, in <module>
print(pytesseract.image_to_string(im))
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string
config=config)
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract
stderr=subprocess.PIPE)
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "C:\Users\NeusAap\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1224, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Process finished with exit code 1
我知道tesseract和pytesseract都有效,因为如果我从CMD运行它:
python pytesseract.py -l eng+nld test.png
它确实有效,并按预期返回给我的字符 我究竟做错了什么?
提前致谢!
Mats de Waard
答案 0 :(得分:1)
我终于开始工作了。似乎一切都设置正确,我正在调用一切正确,但我需要重启Windows,因为Python无法找到文件。
我忘了Windows调试总是从重启开始:P