我在 python 中使用 tesseract 包时出错
I get error using tesseract package in python
我正在尝试使用 pytesseract OCR 阅读支票中的文本。我已经安装了此任务所需的 python 包,例如pip 安装 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>'
您需要安装tesseract可执行文件并将路径包含到程序中然后它不会给出任何错误
我正在尝试使用 pytesseract OCR 阅读支票中的文本。我已经安装了此任务所需的 python 包,例如pip 安装 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>'
您需要安装tesseract可执行文件并将路径包含到程序中然后它不会给出任何错误