ocrmypdf/OCRmyPDF · error · MissingDependencyError

OCR engine does not have language data for the following req

Error message

OCR engine does not have language data for the following requested languages: \n{lang_text}\nPlease install the appropriate language data for your OCR engine.\n\nSee the online documentation for instructions:\n    https://ocrmypdf.readthedocs.io/en/latest/languages.html\n\nNote: most languages are identified by a 3-letter ISO 639-2 Code.\nFor example, English is 'eng', German is 'deu', and Spanish is 'spa'.Simplified Chinese is 'chi_sim' and Traditional Chinese is 'chi_tra'.\n

What it means

Raised when one or more requested OCR languages are not installed for the OCR engine (Tesseract). The message lists the missing codes and points to the language documentation.

Source

Thrown at src/ocrmypdf/_validation.py:86

    missing_languages = set(options.languages) - set(ocr_engine_languages)
    if missing_languages:
        lang_text = '\n'.join(lang for lang in missing_languages)
        msg = (
            "OCR engine does not have language data for the following "
            "requested languages: \n"
            f"{lang_text}\n"
            "Please install the appropriate language data for your OCR engine.\n"
            "\n"
            "See the online documentation for instructions:\n"
            "    https://ocrmypdf.readthedocs.io/en/latest/languages.html\n"
            "\n"
            "Note: most languages are identified by a 3-letter ISO 639-2 Code.\n"
            "For example, English is 'eng', German is 'deu', and Spanish is 'spa'.\n"
            "Simplified Chinese is 'chi_sim' and Traditional Chinese is 'chi_tra'."
            "\n"
        )
        raise MissingDependencyError(msg)


def check_options_sidecar(options: OcrOptions) -> None:
    if options.sidecar == '\0':
        if options.output_file == '-':
            raise BadArgsError("--sidecar filename needed when output file is stdout.")
        elif options.output_file == os.devnull:
            raise BadArgsError(
                "--sidecar filename needed when output file is /dev/null or NUL."
            )
        elif not isinstance(options.output_file, str | Path):
            # The '\0' sentinel is only ever set by the CLI, which always
            # supplies output_file as a plain path - not a stream. If this
            # somehow fires, the caller mixed a CLI-only sentinel with the
            # stream-based API.
            raise BadArgsError(
                "--sidecar filename needed when output file is not a path."
            )

View on GitHub (pinned to 5074a0b0e1)

Solutions

  1. Install the missing language pack (Debian/Ubuntu: apt install tesseract-ocr-<code>; macOS: brew install tesseract-lang; Windows: download .traineddata from tessdata_fast)
  2. Verify available languages with tesseract --list-langs
  3. Fix the code: use 3-letter ISO 639-2 codes (deu not de, chi_sim not zh)

Example fix

# before
ocrmypdf -l deu in.pdf out.pdf  # missing
# after (install first)
# apt install tesseract-ocr-deu
ocrmypdf -l deu in.pdf out.pdf
Defensive patterns

Strategy: validation

Validate before calling

import subprocess
available = set(subprocess.run(['tesseract','--list-langs'], capture_output=True, text=True).stdout.split()[1:])
missing = set(requested_langs) - available
if missing: install_or_abort(missing)

Try / catch

catch ocrmypdf.MissingDependencyError, print install command per code, fail fast

Prevention

When it happens

Trigger: options.languages containing codes absent from the engine's available language set, e.g. -l deu when only eng tessdata is installed; raised as MissingDependencyError in check_options_languages.

Common situations: Fresh Tesseract installs without extra language packs; typo'd codes like 'de' instead of 'deu' or 'zh' instead of 'chi_sim'; missing chi_sim/chi_tra packs for Chinese.

Related errors


AI-assisted analysis of ocrmypdf/OCRmyPDF@5074a0b0e1 (2026-08-27). Data as JSON: /api/errors/86a8fc53c911dac8. Report an issue: GitHub.