[英]Problem occurred when using PyTesseract to recognize text from an image
我試圖為我們的學校網站制作一個自動登錄程序,這需要從驗證碼中識別文本。 所以我從pip安裝了pytesseract
,並在PyCharm中運行了程序:(圖片在目錄/Users/macintosh/Documents/PythonOutputs/2.jpg )
import pytesseract
from PIL import Image
image = Image.open("/Users/macintosh/Documents/PythonOutputs/2.jpg")
text = pytesseract.image_to_string(image)
print(text)
但是出現了這個錯誤:
回溯(最近一次通話):文件“/Users/macintosh/Library/Preferences/PyCharmCE2018.2/scratches/scratch_3.py”,第 5 行,文本 = pytesseract.image_to_string(image)
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytesseract/pytesseract.py”,第 294 行,在 image_to_string 中 return run_and_get_output(*args)
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytesseract/pytesseract.py”,第202行,在run_and_get_output run_tesseract(**kwargs)
文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytesseract/pytesseract.py”,第 178 行,在 run_tesseract 中引發 TesseractError(status_code, get_errors(error_string))
pytesseract.pytesseract.TesseractError: (2, '用法:python pytesseract.py [-l lang] input_file')
有什么問題?
好吧,雖然你的錯誤信息不是很清楚,但我敢打賭(從你的行為來看)你還沒有安裝Tesseract本身。
在 pytessaract 文檔中,它指出:
Python-tesseract 是 Google 的 Tesseract-OCR 引擎的包裝器。
所以你應該安裝實際的程序(即 Tesseract)來完成這項工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.