{"record":{"id":"6b8c224d1644f42c","repo":"docling-project/docling","slug":"nemotron-ocr-requires-python-3-12","errorCode":null,"errorMessage":"Nemotron OCR requires Python 3.12.","messagePattern":"Nemotron OCR requires Python 3\\.12\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"docling/models/stages/ocr/nemotron_ocr_model.py","lineNumber":155,"sourceCode":"                    'via `pip install \"docling[feat-ocr-nemotron]\"` on Linux x86_64 with '\n                    \"Python 3.12 and CUDA 13.x.\"\n                ) from exc\n\n            # Resolve the request language\n            language = resolve_nemotronocr_language(options.lang)\n\n            # Initialize the model\n            model_dir = self._resolve_model_dir(language, artifacts_path=artifacts_path)\n\n            self.reader = NemotronOCRV2(\n                model_dir=None if model_dir is None else str(model_dir),\n                lang=language,\n            )\n\n    @staticmethod\n    def _fail_runtime(message: str) -> None:\n        _log.error(message)\n        raise RuntimeError(message)\n\n    @classmethod\n    def validate_runtime(cls, accelerator_options: AcceleratorOptions) -> None:\n        if sys.platform != \"linux\":\n            cls._fail_runtime(\"Nemotron OCR is only supported on Linux.\")\n\n        if platform.machine() != \"x86_64\":\n            cls._fail_runtime(\"Nemotron OCR is only supported on x86_64 machines.\")\n\n        if sys.version_info[:2] != (3, 12):\n            cls._fail_runtime(\"Nemotron OCR requires Python 3.12.\")\n\n        requested_device = decide_device(accelerator_options.device)\n        if not requested_device.startswith(\"cuda\"):\n            cls._fail_runtime(\n                \"Nemotron OCR requires a CUDA accelerator. Set \"\n                \"`pipeline_options.accelerator_options.device` to CUDA or AUTO on a \"\n                \"CUDA-enabled machine.\"","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/models/stages/ocr/nemotron_ocr_model.py#L137-L173","documentation":"Nemotron OCR is pinned to Python 3.12 because its optional dependency wheels (docling[feat-ocr-nemotron]) are published only for CPython 3.12. validate_runtime compares sys.version_info[:2] to (3,12) and raises RuntimeError on any other minor version, even if the import somehow succeeded.","triggerScenarios":"Running the Nemotron OCR stage under Python 3.10/3.11/3.13/3.14 — the version check fails during model construction before any work is done.","commonSituations":"Default system Python of a distro not being 3.12; pyenv/conda environments on 3.11 or 3.13; docling dropped into an existing app running a different Python.","solutions":["Create a Python 3.12 environment (pyenv install 3.12 / conda create -n nem python=3.12) and install docling with the extra there.","If you cannot change interpreter version, use another OCR engine via pipeline_options.ocr_options.","Pin the environment (Dockerfile FROM python:3.12) so the constraint is enforced by tooling, not by this error."],"exampleFix":"# before (Python 3.11 env)\npipeline_options.ocr_options = NemotronOcrOptions()  # RuntimeError: requires Python 3.12\n\n# after (terminal)\npyenv install 3.12.7 && pyenv local 3.12.7\npip install \"docling[feat-ocr-nemotron]\"","handlingStrategy":"validation","validationCode":"import sys\n\nassert sys.version_info[:2] == (3, 12), \"Nemotron OCR requires Python 3.12\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the Nemotron pipeline in a pinned python:3.12 environment (Docker or pyenv).","Assert the interpreter version at startup before selecting the engine.","Keep the Nemotron-using service isolated from apps on other Python versions."],"tags":["nemotron","ocr","python-version","environment"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}