我如何解决TesseractNotFoundError?

问题描述 投票:50回答:21

我正在尝试在python中使用pytesseract,但我总是遇到以下错误:

    raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path

但是,我的系统上安装了pytesseract和Tesseract。

产生此错误的示例代码:

import cv2
import pytesseract

img = cv2.imread('1d.png')
print(pytesseract.image_to_string(img))
python python-3.x tesseract python-tesseract
21个回答
43
投票

2
投票

1
投票
以下三个命令将满足需要:

sudo apt update # This will update your packages sudo apt install tesseract-ocr # This will install OCR sudo apt install libtesseract-dev # This will add it as development dependency


1
投票

注意:仅适用于Windows


1
投票

0
投票

我也面临同样的问题,只需将C:\Program Files (x86)\Tesseract-OCR添加到您的path变量中。如果仍然不起作用,请在新行中将C:\Program Files (x86)\Tesseract-OCR\tessdata添加到路径变量中。并且不要忘记在添加path变量后重新启动计算机。


0
投票

0
投票

0
投票
which pip3显示pip3安装的路径,which python3显示Python安装的对应路径。

0
投票

当我尝试使用pytesseract制作文本提取程序时,我也遇到了相同的错误,但是在pypi站点中的

pytesseract

的安装说明中有解决方案:pytesseract有很多避免错误的方法,但是,在方法

pytesseract.image_to_string


0
投票

当当前目录位于与tesseract安装位置不同的驱动器上时,在Windows(至少在tesseract版本3.05中)下发生。tesseract中的某些功能期望数据文件位于\ Program Files ...(而不是C:\ Program Files)中。因此,如果您与tesseract不在同一个驱动器号上,它将失败。如果能够解决该问题,那就是在执行tesseract之前临时将驱动器(仅在Windows下)更改为tesseract安装驱动器,然后再进行更改,就可以解决此问题。您的示例:您可以将yourmodule_python.py复制到“ C /程序文件(x86)/ Tesseract-OCR /”并运行!


25
投票
在Mac上

brew install tesseract

在Windows上>
https://github.com/UB-Mannheim/tesseract/wiki下载二进制文件。然后将pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'添加到脚本中。 (如有必要,请替换tesseract二进制文件的路径)

参考:https://pypi.org/project/pytesseract/(“安装”部分)和https://github.com/tesseract-ocr/tesseract/wiki#installation

您可能丢失了计算机的tesseract-ocr。在此处查看安装说明:https://github.com/tesseract-ocr/tesseract/wiki

在Mac上,您只能使用自制软件进行安装:


0
投票

设置路径的步骤很少

1:转到此“ https://github.com/UB-Mannheim/tesseract/wiki

2:下载最新的安装程序
3:安装它
4:在系统变量中设置路径,例如“ C:\ Program Files \ Tesseract-OCR”或“ C:\ ProgramFiles(x86)\ Tesseract-OCR”

5:打开CMD类型“ tesseract”和一些输出,但不包含“非矩形类型错误”


0
投票

16
投票

8
投票
https://github.com/tesseract-ocr/tesseract/wiki下载tesseract并安装它。 Windows版本在这里可用:https://github.com/UB-Mannheim/tesseract/wiki

7
投票

7
投票

4
投票

3
投票

2
投票

对于Mac:

安装Pytesseract(

pip install pytesseract
应该可以)
© www.soinside.com 2019 - 2024. All rights reserved.