OCR:光学识别符,tesserocr是python中一个OCR识别库,是对tesseract做的一个python的 API封装,所以它的核心是tesseract
在这里我安装的版本是:tesseract-ocr-setup-3.05.02-20180621.exe
RuntimeError: Failed to init API, possibly an invalid tessdata path: E:\python36\报错-LMLPHP

在这里勾选 ADditional language data(download)选项来安装OCR识别的语言包,这样可以识别多国语言,然后在一直点击Next

安装下来后配置环境变量

RuntimeError: Failed to init API, possibly an invalid tessdata path: E:\python36\报错-LMLPHP

验证安装成功

RuntimeError: Failed to init API, possibly an invalid tessdata path: E:\python36\报错-LMLPHP

安装完成后将 C:\Program Files\Tesseract-OCR中的tessdata复制一份到python解释器文件中,放入与Lib同级目录中

下一步安装

pip install tesserocr pillow

这里安装会出现问题

RuntimeError: Failed to init API, possibly an invalid tessdata path: E:\python36\报错-LMLPHP

我的解决办法是:在这里下载对于的.whl文件

下载地址:https://github.com/simonflueckiger/tesserocr-windows_build/releases

我下载的版本为:tesserocr-2.2.2-cp36-cp36m-win_amd64.whl

将文件复制到c盘中进行安装

RuntimeError: Failed to init API, possibly an invalid tessdata path: E:\python36\报错-LMLPHP

安装完成后验证图片

RuntimeError: Failed to init API, possibly an invalid tessdata path: E:\python36\报错-LMLPHP

使用终端验证

RuntimeError: Failed to init API, possibly an invalid tessdata path: E:\python36\报错-LMLPHP

使用pycharm验证

import tesserocr
from PIL import Image
image=Image.open('image.png')
result=tesserocr.image_to_text(image)
print(result)

在这里会报错:

RuntimeError: Failed to init API, possibly an invalid tessdata path: E:\python36\报错-LMLPHP

我的解决办法是讲python36整个文件夹复制到E盘中

得到结果:

RuntimeError: Failed to init API, possibly an invalid tessdata path: E:\python36\报错-LMLPHP

05-26 21:52