你好,游客 登录 注册 搜索
背景:
阅读新闻

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

[日期:2017-03-21] 来源:Linux社区  作者:junbujianwpl [字体:大 中 小]

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

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

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-03/142019.htm

linux
相关资讯       FileNotFoundError 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款