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
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯繫作者獲得授權並註明出處。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章