問(wèn)題:pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it’s not in your PATH.
1 電腦安裝tesseract
tesseract下載地址
一路默認(rèn)安裝,最后安裝地址選擇了D盤
配置path環(huán)境變量
cmd中 輸入tesseract,安裝成功
2 python 依賴包
conda install pytesseract
# encoding: utf-8
from PIL import Image
import pytesseract
imageurl = './index.png'
image = Image.open(imageurl)
# 轉(zhuǎn)為會(huì)讀圖像
grayIMG = image.convert('L')
# 對(duì)圖像進(jìn)行二值化處理
threshold = 127
print(grayIMG,'grayimage')
binary_image = grayIMG.point(lambda p: p>threshold and 225)
# 使用tesseract ocr進(jìn)行數(shù)字識(shí)別
code = pytesseract.image_to_string(binary_image,config='--psm 10 --oem 3 -c tessedit_char_whitelist=0123456789')
# print('result is ***',code)
還是報(bào)錯(cuò)
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.
打開(kāi)報(bào)錯(cuò)文件,pytesseract.py,重新配置tesseact地址
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-777571.html
tesseract_cmd = r'D:/Program Files/Tesseract-OCR/tesseract.exe'
再次運(yùn)行測(cè)試代碼,可以跑通文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-777571.html
到了這里,關(guān)于python報(bào)錯(cuò):tesseract is not installed or it‘s not in your PATH.的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!