我正在尝试使用 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
它确实有效,并按预期返回了我的字符。
我究竟做错了什么?
提前致谢!
马茨·德瓦尔德
最佳答案
我终于成功了。似乎一切都设置正确,并且我正确调用了一切,但我需要重新启动 Windows,因为 Python 无法找到这些文件。
我忘记了 Windows 调试总是从重新启动开始:P
关于python - Pytesseract 回溯错误 "file not found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39916515/