使用ocr识别验证码遇到的FileNotFoundError: [WinError 2] The system cannot find the file specified 问题

from PIL import Image
import pytesseract
img = Image.open(r'E:\evns\article_spider\Lib\site-packages\pytesseract\test.PNG')
img = img.convert('L')
pytesseract.image_to_string(img)

首先安装tesseract-ocr,安装好后初次执行以上语句报错:FileNotFoundError: [WinError 2] The system cannot find the file specified 。

通过在github上查找解决办法,调试验证后发现原因是是没把tesseract-ocr.exe安装路经set到系统PATH中。或者将pytesseract.py的tesseract_cmd = 'tesseract' 改成以上路径。

猜你喜欢

转载自blog.csdn.net/sinat_40557813/article/details/80307911
今日推荐