没有这样的文件或目录: 'tesseract': 'tesseract' 即使在 pytesseract.py 中指定了在哪里找到 tesseract

Cha*_*e22 6 python tesseract python-3.x python-tesseract

所以我一直在研究这个问题一段时间,而其他人也有类似的问题,但对我没有任何帮助:

我正在尝试将 pytesseract 用于一个项目,并将其安装在 User/Environments/testEnv/lib/python3.6/site-packages/pytesseract/

我在下面安装了tesseract usr/local/bin

我已经进入Users/User/Environments/testEnv/lib/python3.6/site-packages/pytesseract/pytesseract.py并改变tesseract_cmd = 'tesseract'tesseract_cmd = '/usr/local/bin/tesseract'如下建议:OSERROR:[错误2]没有这样的文件或目录使用pytesser

这没有用。我试图运行这个:

try:
    import Image
except ImportError:
    from PIL import Image
import pytesseract

img = Image.open('screenshot.png')
img.load()
i = pytesseract.image_to_string(img)
print (i)
Run Code Online (Sandbox Code Playgroud)

我明白了:

Traceback (most recent call last):
  File "/Users/User/Environments/testEnv/testTess.py", line 26, in <module>
    i = 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 709, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract': 'tesseract'
Run Code Online (Sandbox Code Playgroud)

这告诉我即使我在pytesseract.py. 这让我很困惑。

注意:您可能会知道,但我使用的是 virtualenv - 由于 tesseract 不在环境中而 pytesseract 在环境中,这可能是一个问题吗?

我使用的是 mac osx 和 python3.6。

我是编码新手,我根本找不到解决此问题的方法。

谢谢!

更新:我现在已经重新下载了 tesseract 并再次尝试了这个,并且还尝试将 tesseract 放在这里:/Users/User/Environments/testEnv/bin/tesseract/3.05.01/bin/tesseract 所以这是在环境中以防出现问题。

我仍然无法使任何工作!绝对任何建议都会有所帮助。

最终更新:我放弃了环境并删除了它并且程序运行了。

Sal*_*man 8

你应该首先tesseract-ocr像这样安装:

在 Linux 上: sudo apt-get install tesseract-ocr

在苹果机上: brew install tesseract

欲了解更多信息,请参阅:此链接