没有这样的文件或目录:'tesseract'

时间:2017-09-18 12:53:10

标签: python-3.x python-tesseract

我安装了“pytesseract”和“tesseract”,但我一直收到错误:

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

……$ pip install pytesseract
Requirement already satisfied: pytesseract in ./anaconda/lib/python3.6/site-packages
Requirement already satisfied: Pillow in ./anaconda/lib/python3.6/site-packages (from pytesseract)
Requirement already satisfied: olefile in ./anaconda/lib/python3.6/site-packages (from Pillow->pytesseract)

……$ pip install tesseract
Requirement already satisfied: tesseract in ./anaconda/lib/python3.6/site-packages

1 个答案:

答案 0 :(得分:0)

由于您正在使用anaconda提示符运行应用程序,因此必须在调用tesseract之前在代码中指定tesseract可执行文件的位置。

pytesseract.pytesseract.tesseract_cmd = '<path_to_tesseract>'

示例:

我正在使用Windows,看起来像

pytesseract.pytesseract.tesseract_cmd = r'C:\Users\myusername\AppData\Local\Tesseract-OCR'

使其在Windows中运行的另一种方法是将tesseract的位置添加到路径环境变量,然后从cmd提示符下执行程序