Python pytesseract : Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory

Viewed 1038

I'm using colab, and this is my code

extractedInformation = pytesseract.image_to_string(Image.open("/content/1.jpeg"),lang='chi_tra')
print(extractedInformation)

and it shows

TesseractError: (1, 'Error opening data file /usr/share/tesseract-ocr/4.00/tessdata/chi_tra.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \'chi_tra\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')

But when I set the lang='eng', it's all working.
I've tried to set

!export TESSDATA_PREFIX="/usr/share/tesseract-ocr/4.00/tessdata"

to point my tessdata directory, but it can't work.
And I checked the available languages by this:

tesseract --list-langs

and

List of available languages (3):
chi_tra
osd
eng

Doesn't that means that I can set the lang='chi_tra'?
That confused me.
Is it a problem with the version of traineddata?

0 Answers
Related