AttributeError:模块'pytesseract'没有属性'run_tesseract'

时间:2019-05-24 04:46:19

标签: python anaconda ocr tesseract

我正在尝试使用run_tesseract函数获取hocr输出,以从银行收据图像的图像中提取文本。但是,我得到了以上错误消息。我已经在笔记本电脑上安装了Tesseract-OCR,并将其路径添加到了System Path变量中。我具有Windows 10 64位操作系统,

我也尝试过卸载并重新安装它,但无济于事。

import glob
import pytesseract
from PIL import Image
img_files=glob.glob('./NACH/*.jpg')
pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files\\Tesseract OCR\\tesseract.exe'
#im=Image.open(img_files[0])
#im.load()
pytesseract.run_tesseract(img_files[0],'output',lang='eng',config='hocr')

我收到以下完整的错误消息:

中的

AttributeError跟踪(最近一次通话最后一次)

4 im = Image.open(img_files [0])

5 im.load()

----> 6 pytesseract.run_tesseract(img_files [0],'输出',lang ='eng',config ='hocr')

7 #text = pytesseract.image_to_string(im)

8 #if os.path.isfile('output.html'):AttributeError:模块'pytesseract'没有属性'run_tesseract'

1 个答案:

答案 0 :(得分:0)

pytesseract.run_tesseract()替换为pytesseract.pytesseract.run_tesseract()

在评论中注明Nithin。将其添加为答案以将其关闭。