{"record":{"id":"0ef5b891f983aaaf","repo":"deepinsight/insightface","slug":"modelscope-is-not-available-please-install-it-wit","errorCode":null,"errorMessage":"ModelScope is not available. Please install it with: pip install modelscope","messagePattern":"ModelScope is not available\\. Please install it with: pip install modelscope","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"cpp-package/inspireface/python/inspireface/modules/utils/resource.py","lineNumber":118,"sourceCode":"            },\n            \"Gundam_RK3588\": {\n                \"url\": \"https://inspireface-1259028827.cos.ap-singapore.myqcloud.com/inspireface_modelzoo/t4/Gundam_RK3588\",\n                \"filename\": \"Gundam_RK3588\",\n                \"md5\": \"66070e8d654408b666a2210bd498a976bbad8b33aef138c623e652f8d956641e\"\n            }\n        }\n\n    def _download_from_modelscope(self, model_name: str) -> str:\n        \"\"\"Download model from ModelScope platform\n        \n        Args:\n            model_name: Name of the model to download\n            \n        Returns:\n            str: Path to the downloaded model file\n        \"\"\"\n        if not MODELSCOPE_AVAILABLE:\n            raise ImportError(\"ModelScope is not available. Please install it with: pip install modelscope\")\n            \n        print(f\"Downloading model '{model_name}' from ModelScope...\")\n        \n        try:\n            # Download specific model file from ModelScope\n            cache_dir = snapshot_download(\n                model_id=self.modelscope_model_id,\n                cache_dir=str(self.modelscope_cache_dir),\n                allow_file_pattern=[model_name]  # Only download the specific model file\n            )\n            \n            model_file_path = Path(cache_dir) / model_name\n            \n            if not model_file_path.exists():\n                raise FileNotFoundError(f\"Model file '{model_name}' not found in downloaded repository\")\n                \n            print(f\"ModelScope download completed: {model_file_path}\")\n            return str(model_file_path)","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/deepinsight/insightface/blob/7fadd420c2351d0ffa8cac403421c1a3ed733365/cpp-package/inspireface/python/inspireface/modules/utils/resource.py#L100-L136","documentation":"_download_from_modelscope re-checks MODELSCOPE_AVAILABLE before calling snapshot_download and raises ImportError with the install hint if the package is missing. Unlike the constructor check, this fires at download time, typically because ModelScope became unavailable after object creation (or the object was constructed in OSS mode and switched).","triggerScenarios":"Calling get_model()/resource download paths that route to _download_from_modelscope_with_cache in an environment where import modelscope fails or wasn't installed.","commonSituations":"Deploying to a container built without modelscope; uninstalling modelscope between process setup and download; a crash of a lazily-imported modelscope submodule setting the availability flag false.","solutions":["pip install modelscope and retry the download","If you can't install it, enable OSS mode first: inspireface.use_oss_download(True)","Verify with python -c 'import modelscope' that the import truly succeeds (watch for conflicting deps)"],"exampleFix":"# before\npath = resource.get_model('pikachu')  # ImportError: ModelScope is not available\n# after\n# pip install modelscope\npath = resource.get_model('pikachu')","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec('modelscope') is None:\n    raise SystemExit('pip install modelscope or call inspireface.use_oss_download(True)')","typeGuard":null,"tryCatchPattern":"try:\n    path = resource.get_model(name)\nexcept ImportError:\n    inspireface.use_oss_download(True)\n    path = resource.get_model(name)","preventionTips":["Verify importability of modelscope in the deploy env, not just pip list","Smoke-test get_model during container build"],"tags":["dependency","modelscope","download","optional-dependency"],"backgroundTag":"missing-optional-dependency","analyzedSha":"7fadd420c2351d0ffa8cac403421c1a3ed733365","analyzedAt":"2026-08-28T15:44:01.850Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}