1

pytesseract.pytesseract.TesseractError: (1, 'Error opening data file \Program Files (x86)\Tesseract-OCR\tessdata/eng.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory. Failed loading language \'eng\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')

Here is the thing i have already placed the tesseract path in my Environment Variable , also i have created a "TESSDATA_PREFIX" variable with the path to the tessdata folder in tesseract by following the answer in this accepted answer, also following on the accepted answer's advice i gave full path to my image locations , but i am still facing the "Could not initialize the tesseract issue"

PS: I do have a file named eng.traineddata at location "C:\Program Files (x86)\Tesseract-OCR\tessdata"

Here's my python code:

from pytesseract import *
pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"
configs = "C:\\Program Files (x86)\\Tesseract-OCR\\tessdata\\configs"
from PIL import Image

print(image_to_string(Image.open('D:\\PycharmFiles\\ImageProcessing\\sample.png')))
print(image_to_string(Image.open('D:\\PycharmFiles\\ImageProcessing\\sample.png'), lang='eng', config=configs))
Carl
  • 365
  • 2
  • 5
  • 17

0 Answers0