简体   繁体   English

AttributeError: 模块“pytesseract”没有属性“run_tesseract”

[英]AttributeError: module 'pytesseract' has no attribute 'run_tesseract'

I am trying to use the run_tesseract function to get an hocr output for extracting text from an image for Bank receipt images.However I am getting the above error message.我正在尝试使用 run_tesseract 函数来获取 hocr 输出,以便从银行收据图像的图像中提取文本。但是我收到了上述错误消息。 I have installed Tesseract-OCR on my laptop, and have also added its path to my System Path variable.I have a windows 10 64 bit operating system,我在我的笔记本电脑上安装了 Tesseract-OCR,并将其路径添加到我的系统路径变量中。我有一个 Windows 10 64 位操作系统,

I have tried uninstalling and reinstalling it also but to no avail.我也尝试卸载并重新安装它,但无济于事。

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')

I get the following complete Error Message:我收到以下完整的错误消息:

AttributeError Traceback (most recent call last) in AttributeError 回溯(最近一次调用最后一次)在

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

5 im.load() 5 im.load()

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

7 #text = pytesseract.image_to_string(im) 7 #text = pytesseract.image_to_string(im)

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

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

Credit Nithin in the comments.在评论中感谢 Nithin。 Adding this as an answer to close it out.添加此作为关闭它的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError:模块“pytesseract.pytesseract”没有属性“pytesseract”。 你的意思是:'run_tesseract'? - AttributeError: module 'pytesseract.pytesseract' has no attribute 'pytesseract'. Did you mean: 'run_tesseract'? AttributeError: 模块“pytesseract”没有属性“image_to_string” - AttributeError: module 'pytesseract' has no attribute 'image_to_string' Flask AttributeError:模块“app”没有属性“run” - Flask AttributeError: module 'app' has no attribute 'run' AttributeError: 模块 'profile' 没有属性 'run' - AttributeError: module 'profile' has no attribute 'run' Python AttributeError:模块“ runAnalytics”没有属性“ run” - Python AttributeError: module 'runAnalytics' has no attribute 'run' AttributeError:模块“ ...”没有属性“ ...” - AttributeError: module '…' has no attribute '…' AttributeError: 模块 ' ' 没有属性 ' ' - AttributeError: module ' ' has no attribute ' ' AttributeError:模块没有属性 - AttributeError: module has no attribute Python3.6 AttributeError:模块'asyncio'没有属性'run' - Python3.6 AttributeError: module 'asyncio' has no attribute 'run' Python 2.7 PyTesseract AttributeError:“ PixelAccess”对象没有属性“ split” - Python 2.7 PyTesseract AttributeError: 'PixelAccess' object has no attribute 'split'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM