无法让 tesseract 在 python 上工作 [英] Trouble getting tesseract to work on python

查看:42
本文介绍了无法让 tesseract 在 python 上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在 jupyter notebook 或 pycharm 上使用 tesseract 运行代码时遇到了一些问题.我怀疑是 Windows 7 上的安装问题,但我不确定我做错了什么.

I'm having some trouble when I try to run a code using tesseract on jupyter notebook or on pycharm. I suspect is a problem with the installation on Windows 7 but I'm not sure what am I doing wrong.

所以我尝试了很多不同的方法,从 pip install tesseract 和 pytesseract 到安装 tesseract OCR(起初我认为这只是一个库,这就是我搞砸了顺序的原因),如下所示:https://github.com/tesseract-ocr/tesseract/wiki我实际上已经下载了这个 Cygwin 和 MSYS2,尽管我看到了一些他们没有安装的 youtube 视频.我什至在我的系统上找到了正确的地址.

So I've tried many different thing, from pip install tesseract and pytesseract to install tesseract OCR (at first I've thought is was just a library that's why I've messed up the order) following this: https://github.com/tesseract-ocr/tesseract/wiki I've actually downloaded this Cygwin and MSYS2 although I've saw some youtube videos in which they didn't install those. And I even path the right address on my system.

好的,所以我使用一个简单的代码来举例说明:

Ok so I'm using a simple code just exemplify:

from PIL import Image                                                           
import pytesseract

img = Image.open("teste.png")
print(img)
text = pytesseract.image_to_string(img)                              
print ('Image text:', text)

错误信息很大,但我认为它会在这一行恢复:

The error message is pretty big but I think it resume itself at this line:

TesseractNotFoundError: C:\Program Files\Tesseract-OCR is not installed or it's not in your path

问题是我在以下位置进行了路径处理:环境变量——路径——编辑——%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Tesseract-OCR

Problem is that I did path it at: Environment variables - path - edit - %SystemRoot%\system32;%SystemRoot%; %SystemRoot%\System32\Wbem; %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\; C:\Program Files\Tesseract-OCR

而且我知道已安装,因为我可以从 cmd 运行它...

And I know is installed because I can run it from cmd...

推荐答案

我在 Windows 中使用 pytesseract 总是有问题,除非我告诉它可执行文件在哪里:

I always have trouble with pytesseract in Windows unless I tell it where the executable is:

pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'

这篇关于无法让 tesseract 在 python 上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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