python报错: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
tesseract下载地址
一路默认安装,最后安装地址选择了D盘
配置path环境变量
python报错:tesseract is not installed or it‘s not in your PATH._第1张图片
cmd中 输入tesseract,安装成功
python报错:tesseract is not installed or it‘s not in your PATH._第2张图片
2 python 依赖包

conda install  pytesseract
# encoding: utf-8
from PIL import Image
import pytesseract
imageurl = './index.png'
image = Image.open(imageurl)
# 转为会读图像
grayIMG = image.convert('L')
# 对图像进行二值化处理
threshold = 127
print(grayIMG,'grayimage')
binary_image = grayIMG.point(lambda p: p>threshold and 225)
# 使用tesseract ocr进行数字识别
code = pytesseract.image_to_string(binary_image,config='--psm 10 --oem 3 -c tessedit_char_whitelist=0123456789')
# print('result is ***',code)

还是报错

File “D:\anaconda\Lib\site-packages\pytesseract\pytesseract.py”,
line 280, in run_tesseract
raise TesseractNotFoundError() pytesseract.pytesseract.TesseractNotFoundError: tesseract is not
installed or it’s not in your PATH. See README file for more
information.

打开报错文件,pytesseract.py,重新配置tesseact地址

python报错:tesseract is not installed or it‘s not in your PATH._第3张图片

tesseract_cmd = r'D:/Program Files/Tesseract-OCR/tesseract.exe'

再次运行测试代码,可以跑通

你可能感兴趣的:(python,python,开发语言)