'Tesseract works but pytesseract is not working with other languages

I have a script which works on Windows but not on Ubuntu.

The problem: pytesseract does not recognize other languages installed.

When I go to the tessdata folder I see this: Ubuntu tessdata

when I run tesseract --list-langs in bash: tesseract --list-langs

but when I go to my python script and apply the lang SPA or SPA_OLD, the result is: Error pytesseract

My configuration of pytesseract:

tessdata_dir_config = '--tessdata-dir "/usr/share/tesseract-ocr/5/tessdata/"'

pytesseract.image_to_string(image,lang="spa", config=tessdata_dir_config+" --dpi 70 --oem 3 --psm 6 -c tessedit_char_whitelist='abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_)/ :.' ").strip()

What am I doing wrong?

If I run tesseract 1.jpeg exp.txt -l spa it works. But not with pytesseract.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source