我尝试在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))
如何解析此TesseractNotFoundError?
发布于 2018-09-09 00:49:28
我得到这个错误是因为我用pip
安装了pytesseract
,但是忘记了安装二进制文件。
在Linux上
sudo apt update
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev
在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
发布于 2018-06-11 17:49:32
您的计算机中可能缺少tesseract-ocr
。请查看此处的安装说明:https://github.com/tesseract-ocr/tesseract/wiki
在Mac上,您可以使用homebrew进行安装:
brew install tesseract
在那之后它应该运行的很好
发布于 2018-11-20 14:33:50
我也面临同样的问题。我只是使用这个命令,它会对我有所帮助。
sudo apt install tesseract-ocr
请注意,这只适用于Ubuntu。
sudo
是Unix独有的命令(Linux、Mac、Rasbian等)。而apt
是特定于Ubuntu的。
https://stackoverflow.com/questions/50655738
复制相似问题