簡體   English   中英

AttributeError: 模塊“pytesseract”沒有屬性“run_tesseract”

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

我正在嘗試使用 run_tesseract 函數來獲取 hocr 輸出,以便從銀行收據圖像的圖像中提取文本。但是我收到了上述錯誤消息。 我在我的筆記本電腦上安裝了 Tesseract-OCR,並將其路徑添加到我的系統路徑變量中。我有一個 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],'output',lang='eng',config='hocr')

7 #text = pytesseract.image_to_string(im)

8 #if os.path.isfile('output.html'):AttributeError: 模塊 'pytesseract' 沒有屬性 'run_tesseract'

pytesseract.run_tesseract()替換為pytesseract.pytesseract.run_tesseract()

在評論中感謝 Nithin。 添加此作為關閉它的答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM