SubtitleEdit/subtitleedit · error · InvalidOperationException

Tesseract not found on PATH. Install it from https://tessera

Error message

Tesseract not found on PATH. Install it from https://tesseract-ocr.github.io/ (or `apt install tesseract-ocr` / `brew install tesseract`) and ensure the binary is on PATH.

What it means

Thrown by TesseractOcrEngine.Create when Detect() walks the PATH environment variable and finds no 'tesseract' (or 'tesseract.exe' on Windows) binary. seconv does not bundle Tesseract; OCR via the tesseract engine requires it installed separately and visible on PATH.

Source

Thrown at src/seconv/Core/TesseractOcrEngine.cs:48

    {
        var name = OperatingSystem.IsWindows() ? "tesseract.exe" : "tesseract";
        var pathEnv = Environment.GetEnvironmentVariable("PATH") ?? string.Empty;
        var separator = OperatingSystem.IsWindows() ? ';' : ':';
        foreach (var dir in pathEnv.Split(separator, StringSplitOptions.RemoveEmptyEntries))
        {
            var candidate = Path.Combine(dir.Trim(), name);
            if (File.Exists(candidate))
            {
                return candidate;
            }
        }
        return null;
    }

    public static TesseractOcrEngine Create(string language = "eng")
    {
        var path = Detect()
            ?? throw new InvalidOperationException(
                "Tesseract not found on PATH. Install it from https://tesseract-ocr.github.io/ " +
                "(or `apt install tesseract-ocr` / `brew install tesseract`) and ensure the binary is on PATH.");

        var workDir = Path.Combine(Path.GetTempPath(), "seconv_ocr_" + Guid.NewGuid().ToString("N"));
        Directory.CreateDirectory(workDir);
        return new TesseractOcrEngine(path, language, workDir);
    }

    /// <summary>
    /// Runs Tesseract on a single bitmap and returns the recognised text. The bitmap is
    /// composited onto white (Tesseract handles antialiased text better with an opaque
    /// background) and scaled up 2× for accuracy on small subtitle bitmaps.
    /// </summary>
    public string Recognize(SKBitmap bitmap)
    {
        if (bitmap is null || bitmap.Width == 0 || bitmap.Height == 0)
        {
            return string.Empty;

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Install Tesseract: apt install tesseract-ocr (Debian/Ubuntu), brew install tesseract (macOS), or the UB Mannheim Windows installer.
  2. Ensure the binary directory is on PATH for the shell/CI that launches seconv (export PATH=...).
  3. Verify with `tesseract --version` in the same environment before retrying.
  4. Pick a different OCR engine if Tesseract is unavailable (--ocr-engine nocr / ollama / paddle).

Example fix

// before
$ seconv movie.sup srt --ocr-engine tesseract  // not installed
// after
$ sudo apt install tesseract-ocr && seconv movie.sup srt --ocr-engine tesseract
Defensive patterns

Strategy: validation

Validate before calling

if (TesseractOcrEngine.Detect() is null)
    throw new InvalidOperationException("Install Tesseract and put it on PATH before OCR.");

Type guard

static bool TesseractAvailable => TesseractOcrEngine.Detect() is not null;

Try / catch

null

Prevention

When it happens

Trigger: TesseractOcrEngine.Create(language) is called (because --ocr-engine tesseract was selected for an image-to-text conversion) and Detect() returns null.

Common situations: Fresh CI/container without Tesseract installed; PATH not propagated to the process; Tesseract installed but only as a Windows Start-menu shortcut, not on PATH; mis-spelling the engine name so the default fell back to tesseract.

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/0040d8eb151c3890. Report an issue: GitHub.