Forums

configuring --tessdata-dir path

i configured my pytesstract path for additional traineddata like below

         PATH = r"/home/wiltomalayalamocr/mysite/langfiles"
         custom_oem_psm_config = '-l {} --psm {} --tessdata-dir {}'.format(lang,6,PATH)
         text = pytesseract.image_to_string(Image.open(filename) , config=custom_oem_psm_config)

my " langfiles" folder contains "mal.traineddata" file. but it always looking its default location and raise the error

pytesseract.pytesseract.TesseractError: (1, 'Tesseract Open Source OCR Engine v3.04.01 with Leptonica Error opening data file /usr/share/tesseract-ocr/tessdata/mal.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory. Failed loading language \'mal\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')

Please help.....

Have you tried to set TESSDATA_PREFIX environment variable to the parent directory of your "tessdata" directory?

$export TESSDATA_PREFIX = /home/wiltomalayalamocr/mysite/langfiles

The above code I typed and tried in Bash Console....But the same error

Is there a tessdata directory in the langfiles directory that contains the file?

No full path is

/home/wiltomalayalamocr/mysite/langfiles/mal.traineddata. When same application is running in my localhost (using local directories in my pc ) its working fine. So I think it is the problem in mentioning the directory path in PythonAnywhere

Are you getting the error message when running code in the bash console where you ran the export command? Or is it somewhere else, like in your website's error log?

[edited by admin: code formatting]

(myvirtualenv) 08:41 ~/mysite $ export TESSDATA_PREFIX=/home/wiltomalayalamocr/mysite/langfiles/
(myvirtualenv) 08:41 ~/mysite $ echo $TESSDATA_PREFIX
/home/wiltomalayalamocr/mysite/langfiles/

error is located in website's error log?

You can find links to your error logs on your Web page on PythonAnywhere. BTW. exporting an environament variable in the console this way will not affect the code in your web app. You should set it inside your WSGI file instead.

We have a help page for that.

horeeeeeeeeeeeeeeeeyyyyyyyyyyyyyyyyyyyyy!!!!!!!!!!!!!!!!!!!!!!!!!! thank its done now it is working.........yaaaaaaaaaaaaaaaaaaaa.......

:-)

Good day! Please help me solve the issue, I cannot repeat your success. Please show me an example of how you did it, maybe I missed or missed something. I cannot install other languages.

What do you mean by "cannot install other languages". What are you doing? What is happening instead? What error messages are you getting?