(OCR error) Failed loading language / Tesseract couldn't load any languages / Could not initialize tesseract (possible solution)

If you are having language problems with OCR like the one above, try this step-by-step guide.
As the error states, you must install the language you need, in my case it is the “Portuguese-BR” language.
Open “Docker Desktop” and click on the 3 dots next to the “app-1” container, after that, click on “open in terminal”:

A local container terminal will open, there you will enter the following commands in order:

sudo apt update
apt list --upgradable
sudo apt upgrade
tesseract --version
sudo apt install tesseract-ocr-por

You can replace “por” (Portuguese) with the language you want.
I believe there is no need to restart any container in docker, just upload a new file to test the OCR. Hope this helps.

You can also use the MAYAN_APT_INSTALLS env variable in your compose file to make the containers install the additional packages automatically. Especially useful in a multi container setup:

MAYAN_APT_INSTALLS=“tesseract-ocr-deu tesseract-ocr-eng”

1 Like