报错信息 Failed to init API, possibly an invalid tessdata path: C:\Users\ylp\PycharmProjects\untitled3\venv\

需要把tesseract的安装目录下的tessdata整个文件夹拷贝到报错路径下的Scripts下

重新运行代码,即可成功识别验证码

import tesserocr
from PIL import Image

image=Image.open(r"C:\Users\ylp\Desktop\code.jpg")
result=tesserocr.image_to_text(image)
print(result)

猜你喜欢

转载自www.cnblogs.com/yaoliping/p/9690024.html