tesseract 'failed loading language eng' on scanned annual report ocr
This skill fixes Tesseract 'failed loading language eng' on scanned annual reports. It locates the real tessdata directory and points TESSDATA_PREFIX at it.
TL;DR
Tesseract's 'failed loading language eng' means the English traineddata file is missing from the tessdata directory it actually reads, which is often not the one you expect. Point TESSDATA_PREFIX at the directory containing eng.traineddata, or install the tesseract-ocr-eng package, and the scanned annual report will OCR.
The error
Error opening data file /usr/share/tesseract-ocr/5/tessdata/eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!Fix it
Find where eng.traineddata actually lives on the system with a filesystem search, for example find / -name 'eng.traineddata'. Expected: Expected: the search returns a real path, possibly under a versioned directory you did not expect.
Set TESSDATA_PREFIX to the parent tessdata directory in the pipeline environment and retry the OCR call. Expected: Expected: tesseract --list-langs shows eng and the OCR run starts.
If no eng.traineddata exists anywhere, install the language data package for your distro (tesseract-ocr-eng on Debian/Ubuntu) or download eng.traineddata into a tessdata dir you control. Expected: Expected: the traineddata file exists and TESSDATA_PREFIX points at it.
Verify on a single scanned page before running the full annual report, and log the TESSDATA_PREFIX value at pipeline startup. Expected: Expected: one page OCRs cleanly and the config is visible in logs for the next debug session.
When to use
- Your scanned-annual-report OCR fails before reading a single page with the language error.
- You need to locate the real tessdata directory versus the assumed one.
- You deploy OCR in containers where language packs are often omitted.
When not to use
- Tesseract loads eng but produces garbage - that is image quality or preprocessing, not this error.
- The error names a different language like 'fra' - install that language pack instead.
- You use a cloud OCR API - then Tesseract is not in the loop at all.
Why it happens
Tesseract separates the engine binary from its language data. Package installs sometimes put traineddata in a versioned path (/usr/share/tesseract-ocr/5/tessdata) while the binary looks elsewhere, or minimal images ship the binary without any language packs. The error names the exact path it tried, which is the fastest clue.
Variant phrasings
tesseract failed loading language eng
Same failure and fix; some searchers phrase the query this way.
tesseract couldn't load any languages fix
Same failure and fix; some searchers phrase the query this way.
Edge cases
- Setting TESSDATA_PREFIX to the tessdata dir itself (not its parent) is the classic misconfiguration.
- Some builds embed a default tessdata path at compile time that ignores the environment variable until you pass --tessdata-dir.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_zajYKPvfRmA8ahDwJocQSQ