首页 > 解决方案 > f"{tesseract_cmd} 未安装或不在您的 PATH 中。"

问题描述

因此,我遵循了有关使用 python 使用 tesseract 的教程,并且我已经从https://github.com/UB-Mannheim/tesseract/wiki安装了 tesseract

并使用:

pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"

在 python 文件中,但仍然得到这样的结果:

 Traceback (most recent call last):
  File ".\testBase.py", line 3, in <module>
    import pytesseract
  File "C:\Python27\lib\site-packages\pytesseract\__init__.py", line 2, in <module>
    from .pytesseract import ALTONotSupported
  File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 89
    f"{tesseract_cmd} is not installed or it's not in your PATH."
                                                                ^
SyntaxError: invalid syntax

而且我正在寻找如何解决它,比如将 tesseract.exe 添加到 PATH 但仍然没有工作。我什至不能在 cmd 上使用 tesseract 命令

有没有我错过的步骤?

谢谢

标签: pythontesseractpython-tesseract

解决方案


我已经通过将 python 版本从 2.7 更新到 3.9 来修复错误


推荐阅读