错误:tesseract 未安装或不在您的 PATH 中

Smi*_*_19 5 python tesseract python-tesseract

我是 pytesseract 和 OCR 的新手,我在互联网上搜索到这是用于从图像中提取文本的工具。但是,我对此工具一无所知。现在,我遇到了这个错误:tesseract 未安装或不在您的路径中。有关详细信息,请参阅自述文件。
我不知道如何解决这个问题,我尝试了在互联网上找到的各种解决方案,但遗憾的是没有奏效。

错误代码:

TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.
Run Code Online (Sandbox Code Playgroud)

对应代码:

!pip install tesseract
import pytesseract
import cv2
from PIL import Image
import matplotlib.pyplot as plt
img = cv2.imread("meter.jpg")
data = pytesseract.image_to_string(img)
print(data)
# plt.imshow(img)
Run Code Online (Sandbox Code Playgroud)

首先告诉你我正在使用 Jupyterhub。事实上,我在我大学的 jupyterhub 上注册了一个帐户。此外,我在网上搜索了可以使用“cmd”并解决问题的地方。如果是这样,请告诉我该怎么做,否则我必须联系大学管理员来解决这个问题。任何帮助表示赞赏!

R. *_*ahy 9

此错误的可能原因是您安装pytesseractpip没有安装二进制文件。如果是这种情况,您可以按如下方式安装:

在Linux上:

sudo apt update
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev
Run Code Online (Sandbox Code Playgroud)

在 Windows 上:从此处下载,然后将二进制路径插入到您的代码中

pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'
Run Code Online (Sandbox Code Playgroud)

在 Mac 上:

brew install tesseract
Run Code Online (Sandbox Code Playgroud)