Reputation: 33
I've seen a lot of other people getting this error, and I've tried a lot of different things to fix it. Nothing so far has worked. I have:
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"
to the programand nothing has changed the error. At this point, I'm just looking for anything. The full error is as follows.
File "pytesseract should work please.py", line 12, in <module>
print(pytesseract.image_to_string(Image.open('text.png')))
File "C:\Users\matth\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 309, in image_to_string
}[output_type]()
File "C:\Users\matth\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 308, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\matth\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 218, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\matth\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 194, in run_tesseract
raise TesseractError(status_code, get_errors(error_string))
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.')
Upvotes: 0
Views: 6305
Reputation: 1
try these steps: step1: Change this path using '/' instead of '\'. e.g., from ==> [1]: pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"
to
[1]: pytesseract.pytesseract.tesseract_cmd = r"C:/Program Files (x86)/Tesseract-OCR/tesseract.exe"
step2: configure to TESSDATA_PREFIX environment using==>
[2]: tessdata_dir_config = r'--tessdata-dir "C:/Program Files (x86)/Tesseract-OCR/tessdata"'
step3:text==>
[3]: pytesseract.image_to_string(Image.open('text.png'),lang='eng',config=tessdata_dir_config)
Upvotes: -1
Reputation: 33
I fixed this issue by fully uninstalling pytesseract and installing an older version (3.2? I think..). So far I haven't noticed any functionality loss. I'm personally just happy that it works.
Upvotes: 1