I have a project where I am using pytesseract. I installed tesseract but every time I am trying to run my code I am getting this error.
pytesseract.pytesseract.TesseractError: (1, 'Error opening data file C:\\Users\\ekrem\\AppData\\Local\\Tesseract-OCR\\tesseract.exe/eng.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language 'eng' Tesseract couldn't load any languages! Could not initialize tesseract.')
I set the TESSDATA_PREFIX:
I am using windows 10.
And here is my code:
import pytesseract
import os
import shutil
pytesseract.pytesseract.tesseract_cmd="C:\\Users\\ekrem\\AppData\\Local\\Tesseract-OCR\\tesseract.exe"
directory='C:\\Users\\ekrem\\Desktop\\resimler'
for filename in os.listdir(directory):
b=os.path.join(directory, filename)
if 'CRN' in pytesseract.image_to_string(b):
print(b)
a=pytesseract.image_to_string(b).index('CRN')
print(pytesseract.image_to_string(b)[a-6:a-1])
else:
destination='C:\\Users\\ekrem\\Desktop\\fails'
c = os.path.join(destination, filename)
shutil.copyfile(b,c)