如何解决 TesseractNotFoundError? [英] How do I resolve a TesseractNotFoundError?
问题描述
我正在尝试在 Python 中使用 pytesseract,但最终总是出现以下错误:
I am trying to use pytesseract in Python but I always end up with the following error:
raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path
然而,pytesseract 和 Tesseract 安装在我的系统上.
However, pytesseract and Tesseract are installed on my system.
产生此错误的示例代码:
Example code that produces this error:
import cv2
import pytesseract
img = cv2.imread('1d.png')
print(pytesseract.image_to_string(img))
我该如何解决这个 TesseractNotFoundError?
How do I resolve this TesseractNotFoundError?
推荐答案
我收到这个错误是因为我用 pip
安装了 pytesseract
但忘记安装二进制文件.>
在 Linux 上
I got this error because I installed pytesseract
with pip
but forget to install the binary.
sudo apt update
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev
在 Mac 上
brew install tesseract
在 Windows 上
On Windows
download binary from https://github.com/UB-Mannheim/tesseract/wiki. then add pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'
to your script. (replace path of tesseract binary if necessary)
参考资料:https://pypi.org/project/pytesseract/(安装部分)和https://github.com/tesseract-ocr/tesseract/wiki#installation
references: https://pypi.org/project/pytesseract/ (INSTALLATION section) and https://github.com/tesseract-ocr/tesseract/wiki#installation
这篇关于如何解决 TesseractNotFoundError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!