按照这个https://germey.gitbooks.io/python3webspider/content/1.3.4-Tesserocr%E7%9A%84%E5%AE%89%E8%A3%85.html 文档安装tesserocr,用来识别验证码,出现的问题:
- 安装 pip3 install tesserocr pillow 出现的问题:
解决方案: 下载whl: https://github.com/simonflueckiger/tesserocr-windows_build/releases
我电脑是64位的,不知道为什么要下载32的才行,可能是我的python是32位的吧
然后执行 pip install C:\Users\Administrator\Desktop\tesserocr-2.4.0-cp36-cp36m-win32.whl - 安装成功后,运行出现的的问题:
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))
解析的图片为
欢迎关注我的公众号,一起进步: