我是 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/