{"record":{"id":"2252b1edf51f120a","repo":"PaddlePaddle/PaddleOCR","slug":"invalid-ocr-version-ocr-version-supported-valu","errorCode":null,"errorMessage":"Invalid OCR version: {ocr_version}. Supported values are {_SUPPORTED_OCR_VERSIONS}.","messagePattern":"Invalid OCR version: (.+?)\\. Supported values are (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"paddleocr/_pipelines/ocr.py","lineNumber":98,"sourceCode":"        text_recognition_batch_size=None,\n        use_doc_orientation_classify=None,\n        use_doc_unwarping=None,\n        use_textline_orientation=None,\n        text_det_limit_side_len=None,\n        text_det_limit_type=None,\n        text_det_thresh=None,\n        text_det_box_thresh=None,\n        text_det_unclip_ratio=None,\n        text_det_input_shape=None,\n        text_rec_score_thresh=None,\n        return_word_box=None,\n        text_rec_input_shape=None,\n        lang=None,\n        ocr_version=None,\n        **kwargs,\n    ):\n        if ocr_version is not None and ocr_version not in _SUPPORTED_OCR_VERSIONS:\n            raise ValueError(\n                f\"Invalid OCR version: {ocr_version}. Supported values are {_SUPPORTED_OCR_VERSIONS}.\"\n            )\n\n        if all(\n            map(\n                lambda p: p is None,\n                (\n                    text_detection_model_name,\n                    text_detection_model_dir,\n                    text_recognition_model_name,\n                    text_recognition_model_dir,\n                ),\n            )\n        ):\n            det_model_name, rec_model_name = self._get_ocr_model_names(\n                lang, ocr_version\n            )\n            if det_model_name is None or rec_model_name is None:","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_pipelines/ocr.py#L80-L116","documentation":"PaddleOCR pipeline (paddleocr/_pipelines/ocr.py) validates the ocr_version keyword at construction time and raises ValueError when it is not None and not in _SUPPORTED_OCR_VERSIONS, which for this module is ['PP-OCRv3','PP-OCRv4','PP-OCRv5','PP-OCRv6']. The check runs before any model download, so it fails fast on a typo'd or outdated version string.","triggerScenarios":"Calling PaddleOCR(ocr_version='PP-OCR'), PaddleOCR(ocr_version='pp-ocrv5') (case-sensitive), PaddleOCR(ocr_version='PP-OCRv2'), or any string outside the supported list.","commonSituations":"Copy-pasting config from old PaddleOCR tutorials that use PP-OCRv2 or PP-OCR; assuming the flag is case-insensitive; mixing the ocr.py supported list (includes PP-OCRv6) with pp_structurev3's shorter list (only v3–v5).","solutions":["Use an exact supported string, e.g. ocr_version='PP-OCRv5' (or omit it to get the default latest).","Check the case: the comparison is exact, 'pp-ocrv5' will not match 'PP-OCRv5'.","If you need a version like PP-OCRv2, pin an older paddleocr release that supports it."],"exampleFix":"# before\nocr = PaddleOCR(ocr_version='PP-OCRv2')  # ValueError\n# after\nocr = PaddleOCR(ocr_version='PP-OCRv5')","handlingStrategy":"validation","validationCode":"from paddleocr._pipelines.ocr import _SUPPORTED_OCR_VERSIONS\n\ndef valid_ocr_version(v: str) -> bool:\n    return v is None or v in _SUPPORTED_OCR_VERSIONS","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Source version strings from _SUPPORTED_OCR_VERSIONS rather than hardcoding","The check is case-sensitive: always use the canonical 'PP-OCRvN' casing","Note the ocr.py list differs from pp_structurev3.py — validate against the pipeline you use"],"tags":["ocr","config","version-validation","valueerror","pipeline"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}