【问题标题】:Pytesseract traceback error "file not found"Pytesseract 回溯错误“找不到文件”
【发布时间】:2017-12-01 19:31:38
【问题描述】:

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

它确实有效,并按预期返回字符。
我究竟做错了什么?

提前致谢!
席德瓦德

【问题讨论】:

    标签: python python-3.x tesseract


    【解决方案1】:

    我终于让它工作了。似乎一切都设置正确,并且我正确调用了所有内容,但我需要重新启动 Windows,因为 Python 找不到这些文件。

    我忘记了 Windows 调试总是从重新启动开始:P

    【讨论】:

      猜你喜欢
      • 2016-08-17
      • 2018-10-21
      • 1970-01-01
      • 2016-03-17
      • 2022-10-09
      • 2018-08-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多