在windows操作系統中,當使用pytesseract對圖像中的驗證碼進行識別時會遇到以下問題:
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path
給出以下解決方案:
(1)首先下載tesseract-ocr。
下載地址為藍奏雲網盤:https://wws.lanzous.com/iFyShmujych
密碼:5nc2
下載成功之后,對下圖所示的文件進行安裝, 不過在安裝時要記住安裝的目錄。
(2)安裝文件
安裝成功之后,打開安裝的文件所在的目錄。例如我的安裝目錄為:S:\Programs\Python\Python37-32\Tesseract-OCR\tesseract.exe。
(3)配置路徑
對畫紅圈的地方中的‘tesseract’修改為安裝tesseract-ocrde的安裝目錄。我安裝在D:\tesseract\Tesseract-OCR\tesseract.exe
重新運行程序即可。
from PIL import Image
import pytesseract
num_1 = Image.open(r'.\imgs\2.png')
print(pytesseract.image_to_string(num_1))
原文地址https://blog.csdn.net/weixin_41644725/article/details/9534492