WindowsError:[错误2]系统找不到为pytesseract指定的文件 [英] WindowsError: [Error 2] The system cannot find the file specified for pytesseract

查看:114
本文介绍了WindowsError:[错误2]系统找不到为pytesseract指定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用pytesseract进行OCR,但出现Windows错误.请帮助.

I am trying to do OCR using pytesseract but getting an Windowserror. Kindly help.

from PIL import Image
from pytesseract import image_to_string
import matplotlib.pyplot as plt

加载图像

im = Image.open('image_112472.jpg') # the second one
im.load()

打印文本

print(image_to_string(im,lang='eng'))

我遇到以下错误

Traceback (most recent call last):


 File "C:/Users/amuly/PycharmProjects/P1/Teeth_detection/test1.py", line 17, in <module>
    print(image_to_string(im,lang='eng'))
  File "C:\Users\amuly\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
    config=config)
  File "C:\Users\amuly\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
    proc = subprocess.Popen(command, stderr=subprocess.PIPE)
  File "C:\Users\amuly\Anaconda2\lib\subprocess.py", line 390, in __init__
    errread, errwrite)
  File "C:\Users\amuly\Anaconda2\lib\subprocess.py", line 640, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

推荐答案

您必须确保tesseract.exe在计算机上(例如,通过安装Tesseract-OCR),然后将包含文件夹添加到PATH环境变量中,或使用

You have to make sure tesseract.exe is on your computer (for example by installing Tesseract-OCR), then add the containing folder to your PATH environment variable, or declare it's location using

import pytesseract
pytesseract.pytesseract.tesseract_cmd attribute

这篇关于WindowsError:[错误2]系统找不到为pytesseract指定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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