python - Pytesseract 回溯错误 "file not found"

标签 python python-3.x tesseract

我正在尝试使用 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/

相关文章:

javascript - tesseract.js 示例代码不起作用

python - GDB 崩溃 - 意外的 GDB STDERR : Fatal Python error: Py_Initialize: Unable to get the locale encoding

Python-诅咒 : how to use the inch method to get the attribute of a character

python - 在 QMainWindow __init__() 上发出请求,不延迟打开

python - 我想知道为什么我的玩家和气球都是 Sprite ,当我移动玩家时会出现卡顿

python - Python 3 中的图形、绘图

python - 如何获得 ocr 输出的信任率?

python-3.x - 拟合顺序模型后缺少 val_acc

python - 使用正则表达式忽略不完整的数据集?

java - 苔丝二号和tessdata文件夹