python - 错误 : tesseract is not installed or it's not in your PATH

标签 python tesseract python-tesseract

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

错误代码:

TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.

对应代码:

!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)

首先让我告诉你,我正在使用 Jupyterhub。实际上,我在大学的 jupyterhub 上注册了一个帐户。此外,我在网上搜索了可以使用 'cmd' 的地方并解决了问题。如果是这样,那么请告诉我如何操作,否则我必须联系 Uni 管理员来解决这个问题。感谢您的帮助!

最佳答案

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

在 Linux 上:

sudo apt update
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev

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

pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'

在 Mac 上:

brew install tesseract

关于python - 错误 : tesseract is not installed or it's not in your PATH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68084044/

相关文章:

python - Python 3 的 WSGI 请求和响应包装器

Python:私有(private)内部枚举类中的静态方法

python - 使用 python 和 Tesseract OCR 从文本中提取特定内容

windows - 如何在 Windows 上训练 Tesseract

python - 如何在保留顺序的同时从图表图像中获取数据?

python - 使用正则表达式在 python 中的数据框或列中的大写字母之前添加空格

python - Python 中有 "wildcard method"吗?

python - 使用 pytesseract 时如何设置配置 load_system_dawg 以改善结果?

python - tesseract 从表中读取值

python - 如何使用tesseract从图像的特定坐标提取文本?