ocrmypdf/OCRmyPDF · error · MissingDependencyError

The program '{program}' did not report its version. Message

Error message

The program '{program}' did not report its version. Message was:
{output}

What it means

The program ran successfully but none of its output lines matched the version regex passed to get_version(). The full output is included in the message to aid diagnosis.

Source

Thrown at src/ocrmypdf/subprocess/_version.py:74

        if e.returncode != 0:
            log.exception(e)
            raise MissingDependencyError(
                f"Ran program '{program}' but it exited with an error:\n{e.output}"
            ) from e
        raise MissingDependencyError(
            f"Could not find program '{program}' on the PATH"
        ) from e

    # Some tools (e.g. veraPDF launched on a recent JDK) print warnings before
    # the version line, so scan each line rather than only the start of output.
    version = None
    for line in output.splitlines():
        match = re.match(regex, line.strip())
        if match:
            version = match.group(1)
            break
    if version is None:
        raise MissingDependencyError(
            f"The program '{program}' did not report its version. "
            f"Message was:\n{output}"
        )

    return version

View on GitHub (pinned to 5074a0b0e1)

Solutions

  1. Run the tool's version command manually and adjust the regex to match actual output
  2. Anchor loosely (e.g. r'([0-9]+\.[0-9]+\.[0-9]+)') if only the number matters
  3. Pin/downgrade the tool version whose output your regex was written for
  4. For plugin tools, emit a predictable version line

Example fix

# before
v = get_version('tesseract', regex=r'tesseract v(.*)')  # newer builds print differently
# after
v = get_version('tesseract', regex=r'tesseract[- ]v?(\d[\w.\-]*)')
Defensive patterns

Strategy: validation

Validate before calling

import subprocess\nout = subprocess.run([program, '--version'], capture_output=True, text=True).stdout\nimport re\nassert re.search(regex, out), f'regex does not match tool output: {out!r}'; 

Try / catch

try:\n    v = get_version(program, regex=rx)\nexcept MissingDependencyError:\n    print_actual_output_to_tune_regex(program)

Prevention

When it happens

Trigger: get_version(program, regex=...) where the regex doesn't match any line — e.g. the tool changed its banner format between versions, or warnings were printed instead of a version line.

Common situations: Upgrading tesseract/qpdf/ghostscript changes version-string format; locale settings altering output; custom plugin tools with unexpected banners;veraPDF JDK warnings preceding output (the code scans all lines for this reason).

Related errors


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