{"record":{"id":"46b69883e69cb900","repo":"docling-project/docling","slug":"tesserocr-is-not-correctly-installed-please-insta","errorCode":null,"errorMessage":"tesserocr is not correctly installed. Please install it via `pip install tesserocr` to use this OCR engine. Note that tesserocr might have to be manually compiled for working with your Tesseract installation. The Docling documentation provides examples for it. Alternatively, Docling has support for other OCR engines. See the documentation: https://docling-project.github.io/docling/installation/","messagePattern":"tesserocr is not correctly installed\\. Please install it via `pip install tesserocr` to use this OCR engine\\. Note that tesserocr might have to be manually compiled for working with your Tesseract installation\\. The Docling documentation provides examples for it\\. Alternatively, Docling has support for other OCR engines\\. See the documentation: https://docling-project\\.github\\.io/docling/installation/","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"docling/models/stages/ocr/tesseract_ocr_model.py","lineNumber":70,"sourceCode":"                \"tesserocr is not correctly installed. \"\n                \"Please install it via `pip install tesserocr` to use this OCR engine. \"\n                \"Note that tesserocr might have to be manually compiled for working with \"\n                \"your Tesseract installation. The Docling documentation provides examples for it. \"\n                \"Alternatively, Docling has support for other OCR engines. See the documentation: \"\n                \"https://docling-project.github.io/docling/installation/\"\n            )\n            missing_langs_errmsg = (\n                \"tesserocr is not correctly configured. No language models have been detected. \"\n                \"Please ensure that the TESSDATA_PREFIX envvar points to tesseract languages dir. \"\n                \"You can find more information how to setup other OCR engines in Docling \"\n                \"documentation: \"\n                \"https://docling-project.github.io/docling/installation/\"\n            )\n\n            try:\n                import tesserocr\n            except ImportError:\n                raise ImportError(install_errmsg)\n            try:\n                tesseract_version = tesserocr.tesseract_version()\n            except Exception:\n                raise ImportError(install_errmsg)\n\n            _, self._tesserocr_languages = tesserocr.get_languages()\n            if not self._tesserocr_languages:\n                raise ImportError(missing_langs_errmsg)\n\n            # Initialize the tesseractAPI\n            _log.debug(\"Initializing TesserOCR: %s\", tesseract_version)\n            lang = \"+\".join(self.options.lang)\n\n            if any(lang.startswith(\"script/\") for lang in self._tesserocr_languages):\n                self.script_prefix = \"script/\"\n            else:\n                self.script_prefix = \"\"\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/models/stages/ocr/tesseract_ocr_model.py#L52-L88","documentation":"The tesserocr-based (C API) Tesseract model imports the tesserocr Python package at init. If the import fails, Docling raises this ImportError telling you to install tesserocr and noting it may need manual compilation against your Tesseract libraries, with a pointer to the Docling installation docs.","triggerScenarios":"pipeline_options.ocr_options = TesseractOcrOptions() (the tesserocr engine) in an environment where 'import tesserocr' raises ImportError — package not installed, or installed for a mismatched Python/ABI.","commonSituations":"docling-slim installs without OCR extras; pip-installed tesserocr wheel built against a different Tesseract version; conda/pip interpreter mixups where the package landed in another env.","solutions":["Install tesserocr: pip install tesserocr (or conda install -c conda-forge tesserocr, which bundles matching Tesseract).","If compilation fails, ensure the system Tesseract dev headers (libtesseract-dev, libleptonica-dev) and pkg-config are installed, or use the conda-forge package.","Alternatively switch to the CLI-based engine (tesseract binary on PATH) or another OCR engine supported by Docling."],"exampleFix":"# before\n# ImportError: tesserocr is not correctly installed\n\n# after\n$ conda install -c conda-forge tesserocr\n# or switch engine:\npipeline_options.ocr_options = TesseractCliOcrOptions()","handlingStrategy":"validation","validationCode":"def tesserocr_available() -> bool:\n    try:\n        import tesserocr  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\nif not tesserocr_available():\n    raise SystemExit(\"tesserocr missing: pip install tesserocr (see docling docs)\")","typeGuard":null,"tryCatchPattern":"try:\n    TesseractOcrModel(options=TesseractOcrOptions())\nexcept ImportError as e:\n    if \"tesserocr is not correctly installed\" in str(e):\n        # fall back to the CLI engine, which only needs the binary\n        from docling.models.stages.ocr.tesseract_ocr_cli_model import TesseractOcrCliModel\n        model = TesseractOcrCliModel(options=TesseractCliOcrOptions())\n    else:\n        raise","preventionTips":["Prefer conda-forge for matched tesseract/tesserocr installs.","Smoke-test 'import tesserocr; tesserocr.tesseract_version()' in your build pipeline.","Keep a CLI-engine fallback path for environments where the C extension cannot build."],"tags":["ocr","tesseract","tesserocr","dependency","environment"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}