簡體   English   中英

我在 python 中使用 tesseract 包時出錯

[英]I get error using tesseract package in python

我正在嘗試使用 pytesseract OCR 讀取支票中的文本。 我已經安裝了此任務所需的 Python 包,例如 pip install pytesseract。

但是,當我嘗試使用該包讀取文件時,出現以下錯誤:

 pytesseract.image_to_string(im, lang='eng')
Traceback (most recent call last):

  File "<ipython-input-17-d7d9f430493b>", line 1, in <module>
    pytesseract.image_to_string(im, lang='eng')

  File "C:\Users\BRIGHT\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 294, in image_to_string
    return run_and_get_output(*args)

  File "C:\Users\BRIGHT\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 202, in run_and_get_output
    run_tesseract(**kwargs)

  File "C:\Users\BRIGHT\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 172, in run_tesseract
    raise TesseractNotFoundError()

TesseractNotFoundError: tesseract is not installed or it's not in your path

這個錯誤沒有意義,因為我實際上導入了包而沒有出現任何錯誤。 但是當我嘗試使用它時,我得到了錯誤。

這是我的代碼:

from PIL import Image
import pytesseract

im=Image.open('BritishChequeAnnotated.jpg')
text=pytesseract.image_to_string(im, lang='eng')

tesseract 的文檔清楚地說明了這一點。

https://pypi.org/project/pytesseract/

# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'

您需要安裝teseract可執行文件並將路徑包含在程序中,然后它就不會出現任何錯誤

暫無
暫無

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

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