pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path

windows环境下使用pytesseract识别验证码中文字时报错:

          pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path

pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path_第1张图片

 报错原因很明确: 没有找到 tesseract

 

解决方案:

    1.找到python的安装路径下的pytesseract:   例如我的是   E:\Python3.7.1\Lib\site-packages\pytesseract

pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path_第2张图片

2.用文本编辑器打开,查找tesseract_cmd

将原来的   tesseract_cmd = 'tesseract' 改为:  tesseract_cmd = 'OCR的安装路径下的tessract.exe'

例如我的是   tesseract_cmd = 'C:\Program Files\Tesseract-OCR\\tesseract.exe'

注意有的地方需要转义   例如 \\tesseract.exe,或者也可直接加r转义

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

pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path_第3张图片

3.运行:不报错了

你可能感兴趣的:(Python,OCR)