Pytesseract:“TesseractNotFound 错误:tesseract 未安装或不在您的路径中",我该如何解决? [英] Pytesseract : "TesseractNotFound Error: tesseract is not installed or it's not in your path", how do I fix this?

查看:315
本文介绍了Pytesseract:“TesseractNotFound 错误:tesseract 未安装或不在您的路径中",我该如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 python 中运行一个基本且非常简单的代码.

I'm trying to run a basic and very simple code in python.

from PIL import Image
import pytesseract

im = Image.open("sample1.jpg")

text = pytesseract.image_to_string(im, lang = 'eng')

print(text)

这就是它的样子,我实际上已经通过安装程序为 windows 安装了 tesseract.我对 Python 很陌生,我不确定如何继续?

This is what it looks like, I have actually installed tesseract for windows through the installer. I'm very new to Python, and I'm unsure how to proceed?

这里的任何指导都会非常有帮助.我试过重新启动我的 Spyder 应用程序,但无济于事.

Any guidance here would be very helpful. I've tried restarting my Spyder application but to no avail.

推荐答案

我看到步骤分散在不同的答案中.根据我最近在 Windows 上遇到此 pytesseract 错误的经验,按顺序编写不同的步骤以更容易解决错误:

I see steps are scattered in different answers. Based on my recent experience with this pytesseract error on Windows, writing different steps in sequence to make it easier to resolve the error:

1.使用 Windows 安装程序安装 tesseract:https://github.com/UB-Mannheim/tesseract/wiki

1. Install tesseract using windows installer available at: https://github.com/UB-Mannheim/tesseract/wiki

2.请注意安装中的 tesseract 路径.此编辑时的默认安装路径为:C:\Users\USER\AppData\Local\Tesseract-OCR.它可能会改变,请检查安装路径.

2. Note the tesseract path from the installation. Default installation path at the time of this edit was: C:\Users\USER\AppData\Local\Tesseract-OCR. It may change so please check the installation path.

3.pip 安装pytesseract

4.在调用image_to_string之前在脚本中设置tesseract路径:

4. Set the tesseract path in the script before calling image_to_string:

pytesseract.pytesseract.tesseract_cmd = r'C:\Users\USER\AppData\Local\Tesseract-OCR\tesseract.exe'

这篇关于Pytesseract:“TesseractNotFound 错误:tesseract 未安装或不在您的路径中",我该如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆