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

我安装时出现了以下错误

 

后来通过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
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值