import pytesseract
from PIL import Image
image=Image.open(r"C:\Users\lcega\Desktop\验证码.png")
code=pytesseract.image_to_string(image,lang="chi_sim",config="—psm 3")
print(code)
-
pip install pytesseract
如果原本未安装tesseract 还要去https://github.com/UB-Mannheim/tesseract/wiki下载对应系统的exe安装包。 否则会报错
pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/7a1ed8d84941c7a27261bb70e068414e.png)
Windows系统下载上图的exe。
-
找到使用的python对应的路径下的Lib\site-package\pytesseract\pytesseract.py