WindowsError: [Error 2] The system cannot find the file specified for pytesseract

丶灬走出姿态 提交于 2019-12-12 04:13:53

问题


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

Loading the images

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

Printing the text

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

I am getting the following error

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

回答1:


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


来源:https://stackoverflow.com/questions/44822195/windowserror-error-2-the-system-cannot-find-the-file-specified-for-pytesserac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!