FileNotFoundError: [Errno 2] No such file or directory: ‘tesseract’

报错问题如下

Traceback (most recent call last):
  File "identCode.py", line 36, in <module>
    print(getCode(sys.argv[1]))
  File "identCode.py", line 25, in getCode
    vcode = pytesseract.image_to_string(image)
  File "/usr/local/lib/python3.5/dist-packages/pytesseract/pytesseract.py", line 161, in image_to_string
    config=config)
  File "/usr/local/lib/python3.5/dist-packages/pytesseract/pytesseract.py", line 94, in run_tesseract
    stderr=subprocess.PIPE)
  File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'

解决方案

安装tesseract

sudo apt install tesseract

参见stackoverflow
http://stackoverflow.com/questions/28741563/pytesseract-no-such-file-or-directory-error

tips

此处是在ubuntu1604上出现问题然后解决了。
我之前是在win7下尝试过,相同的代码,总是报错。那么举一反三推测一下,win7下也应当安装tesseract。虽然在win7下安装tesseract之后直接cmd就可以用tesseract命令识别,而且安装的过程极为冗长而且会报错。。。,带了n多语言的库,比如c、Perl、lua等等。以保险起见,windows系列os下要用pytesseract还是将tesseract加以安装。否则可能会有未可知的错误。:)

GitHub 加速计划 / te / tesseract
60.1 K
9.29 K
下载
tesseract-ocr/tesseract: 是一个开源的光学字符识别(OCR)引擎,适用于从图像中提取和识别文本。特点是可以识别多种语言,具有较高的识别准确率,并且支持命令行和API调用。
最近提交(Master分支:2 个月前 )
bc490ea7 Don't check for a directory, because a symbolic link is also allowed. Signed-off-by: Stefan Weil <sw@weilnetz.de> 4 个月前
2991d36a - 4 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐