Python Tesseract“没有这样的文件或目录”

时间:2018-01-11 20:13:15

标签: python tesseract pillow

我正在尝试在python中制作一个OCR程序,并且我正在使用枕头来制作高对比度黑白图像,但是当我尝试使用tesseract来提取文本时,我得到以下错误输出终端:

错误

ERROR: NotAuthorizedError - Operation Denied. The security token included in the request is invalid.

的Python

Traceback (most recent call last):
  File "OCR.py", line 41, in <module>
    print(pytesseract.image_to_string(img))
  File                 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 122, in image_to_string
config=config)
  File     "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-    packages/pytesseract/pytesseract.py", line 46, in run_tesseract
    proc = subprocess.Popen(command, stderr=subprocess.PIPE)
  File     "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess    .py", line 707, in __init__
    restore_signals, start_new_session)
  File     "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess    .py", line 1333, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory:     '/usr/local/bin/tesseract'

1 个答案:

答案 0 :(得分:2)

根据README,您必须安装tesseract才能使用pytesseract。

在Ubuntu上:

sudo apt install tesseract-ocr