{"record":{"id":"6ac0ebdb2697ce7a","repo":"docling-project/docling","slug":"rapidocr-is-not-installed-please-install-it-via","errorCode":null,"errorMessage":"RapidOCR is not installed. Please install it via `pip install rapidocr onnxruntime` to use this OCR engine. Alternatively, Docling has support for other OCR engines. See the documentation.","messagePattern":"RapidOCR is not installed\\. Please install it via `pip install rapidocr onnxruntime` to use this OCR engine\\. Alternatively, Docling has support for other OCR engines\\. See the documentation\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"docling/models/stages/ocr/rapid_ocr_model.py","lineNumber":281,"sourceCode":"        options: RapidOcrOptions,\n        accelerator_options: AcceleratorOptions,\n    ):\n        super().__init__(\n            enabled=enabled,\n            artifacts_path=artifacts_path,\n            options=options,\n            accelerator_options=accelerator_options,\n        )\n        self.options: RapidOcrOptions\n\n        # multiplier for 72 dpi; the default 3.0 == 216 dpi.\n        self.scale = self.options.scale\n\n        if self.enabled:\n            try:\n                from rapidocr import ModelType, OCRVersion, RapidOCR  # type: ignore\n            except ImportError:\n                raise ImportError(\n                    \"RapidOCR is not installed. Please install it via `pip install rapidocr onnxruntime` to use this OCR engine. \"\n                    \"Alternatively, Docling has support for other OCR engines. See the documentation.\"\n                )\n\n            # Decide the accelerator devices\n            device = decide_device(accelerator_options.device)\n            use_cuda = str(AcceleratorDevice.CUDA.value).lower() in device\n            use_dml = accelerator_options.device == AcceleratorDevice.AUTO\n            intra_op_num_threads = accelerator_options.num_threads\n            gpu_id = 0\n            if use_cuda and \":\" in device:\n                gpu_id = int(device.split(\":\")[1])\n            backend_enum = _backend_to_engine_type(self.options.backend)\n\n            # Reduce the user provided language list to one language\n            lang = (\n                self.options.lang[0]\n                if self.options.lang","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/models/stages/ocr/rapid_ocr_model.py#L263-L299","documentation":"When RapidOCR is the enabled OCR engine, Docling imports rapidocr at model initialization. If the import fails (package not installed in this environment), it raises this ImportError with installation guidance instead of a raw ModuleNotFoundError.","triggerScenarios":"Running the pipeline with RapidOcrOptions as the OCR engine (or default resolution picking RapidOCR) in an environment where 'rapidocr' and/or its runtime (e.g. onnxruntime) is missing. Common with docling-slim installs or minimal virtualenvs.","commonSituations":"Using docling-slim without OCR extras; installing rapidocr but not onnxruntime (torch/onnxruntime backends need their runtime dependency); CI images trimmed of optional OCR dependencies.","solutions":["Install the engine: pip install rapidocr onnxruntime (or add the appropriate docling extras).","If you did not intend to use RapidOCR, switch the OCR engine, e.g. OcrOptions(ocr_engine='tesseract'), or disable OCR.","Verify with 'python -c \"import rapidocr\"' in the same interpreter/venv your application runs in."],"exampleFix":"# before (env lacks rapidocr)\n# pipeline with RapidOcrOptions fails at init\n\n# after\n$ pip install rapidocr onnxruntime\n# or: switch engine\npipeline_options.ocr_options = OcrOptions(ocr_engine=\"tesseract\")","handlingStrategy":"validation","validationCode":"def rapidocr_available() -> bool:\n    try:\n        import rapidocr  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\nif ocr_engine == \"rapidocr\" and not rapidocr_available():\n    raise SystemExit(\"rapidocr missing: pip install rapidocr onnxruntime\")","typeGuard":null,"tryCatchPattern":"try:\n    pipeline.initialize()\nexcept ImportError as e:\n    if \"RapidOCR is not installed\" in str(e):\n        # degrade gracefully: disable OCR or switch engine\n        pipeline_options.ocr_options.enabled = False\n        pipeline.initialize()\n    else:\n        raise","preventionTips":["Declare OCR extras in your deployment's dependency manifest (requirements/lockfile).","Smoke-test 'import rapidocr' in the target container image during build.","Use docling full package (not slim) when OCR is required."],"tags":["ocr","rapidocr","dependency","environment"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}