按照这个https://germey.gitbooks.io/python3webspider/content/1.3.4-Tesserocr%E7%9A%84%E5%AE%89%E8%A3%85.html 文档安装tesserocr,用来识别验证码,出现的问题:
RuntimeError: Failed to init API, possibly an invalid tessdata path: D:\softCach\ProgramFile\Tesseract-OCR/
解决方法: 将Tesserocr 安装目录下的 \tessdata 拷贝到 pyhon的安装目录下
并且 环境变量: TESSDATA_PREFIX 设置为 \tessdata的路径,即:
D:\softCach\ProgramFile\Python\Python36-32\Scripts\tessdata
再次运行程序:
import tesserocr
from PIL import Image
image = Image.open('C:/Users/Administrator/Desktop/image.png')
print(tesserocr.image_to_text(image))