Tesserocr在python运用中入的坑

 

这个例程是基于《python3网络爬虫开发实践》一书


以下是测试程序

import tesserocr

from PILimport Image

image = Image.open('image.png')#open image

#print(image)

print(tesserocr.image_to_text(image))


1.安装Tersseract

相关链接:

tesserocr GitHub:https://github.com/sirfz/tesserocr

tesserocr PyPI:https://pypi.python.org/pypi/tesserocr

tesseract下载地址:http : //digi.bib.uni-mannheim.de/tesseract

tesseract GitHub:https://github.com/tesseract-ocr/tesseract

tesseract语言包:https://github.com/tesseract-ocr/tessdata

tesseract文档:https://github.com/tesseract-ocr/tesseract/wiki/Documentation

next到底就行了

2.安装tesserocr和pillow模块

2.1tesserocr

我安装时出现了以下错误

 

Tesserocr在python运用中入的坑_第1张图片

后来通过whl来安装才最终成功的

whl安装包下载链接

Releases · simonflueckiger/tesserocr-windows_build · GitHub

把下载下来的安装包放在python安装路径里

选择合适的版本下载   运行pip3 install tesserocr-2.2.2-cp36-cp36m-win_amd64.whl

加粗斜体的是下载下来的文件名。

2.2安装pillow

没什么问题 直接运行  pip3 install pillow就行了 若还是有问题,应该也可以用whl进行安装

3在pycharm运行出现报错的原因

出现以下报错

Failed to init API, possibly an invalid tessdata path: C:\\

解决办法是将C:\Program Files (x86)\Tesseract-OCR  的tessdata文件夹copy到python的安装路径中



作者:Flying_3e02
链接:https://www.jianshu.com/p/dcad7ee3b162
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

 

你可能感兴趣的:(python)