{"record":{"id":"ce67c5d7e0f08ae2","repo":"open-mmlab/mmdetection","slug":"package-lvis-is-not-installed-please-run-pip-ins-ce67c5","errorCode":null,"errorMessage":"Package lvis is not installed. Please run \"pip install git+https://github.com/lvis-dataset/lvis-api.git\".","messagePattern":"Package lvis is not installed\\. Please run \"pip install git\\+https://github\\.com/lvis-dataset/lvis-api\\.git\"\\.","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"mmdet/evaluation/metrics/lvis_metric.py","lineNumber":95,"sourceCode":"    \"\"\"\n\n    default_prefix: Optional[str] = 'lvis'\n\n    def __init__(self,\n                 ann_file: Optional[str] = None,\n                 metric: Union[str, List[str]] = 'bbox',\n                 classwise: bool = False,\n                 proposal_nums: Sequence[int] = (100, 300, 1000),\n                 iou_thrs: Optional[Union[float, Sequence[float]]] = None,\n                 metric_items: Optional[Sequence[str]] = None,\n                 format_only: bool = False,\n                 outfile_prefix: Optional[str] = None,\n                 collect_device: str = 'cpu',\n                 prefix: Optional[str] = None,\n                 file_client_args: dict = None,\n                 backend_args: dict = None) -> None:\n        if lvis is None:\n            raise RuntimeError(\n                'Package lvis is not installed. Please run \"pip install '\n                'git+https://github.com/lvis-dataset/lvis-api.git\".')\n        super().__init__(collect_device=collect_device, prefix=prefix)\n        # coco evaluation metrics\n        self.metrics = metric if isinstance(metric, list) else [metric]\n        allowed_metrics = ['bbox', 'segm', 'proposal', 'proposal_fast']\n        for metric in self.metrics:\n            if metric not in allowed_metrics:\n                raise KeyError(\n                    \"metric should be one of 'bbox', 'segm', 'proposal', \"\n                    f\"'proposal_fast', but got {metric}.\")\n\n        # do class wise evaluation, default False\n        self.classwise = classwise\n\n        # proposal_nums used to compute recall or precision.\n        self.proposal_nums = list(proposal_nums)\n","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/evaluation/metrics/lvis_metric.py#L77-L113","documentation":"LVISMetric.__init__ raises RuntimeError when the optional `lvis` package (LVIS API) is not importable. mmdet imports lvis lazily/optionally because it is not a hard dependency, and LVIS-based evaluation is impossible without it.","triggerScenarios":"Instantiating LVISMetric (config with val_evaluator=dict(type='LVISMetric')) in an environment where `import lvis` failed, so the module-level lvis symbol is None.","commonSituations":"Running LVIS dataset evaluation in a fresh mmdet install without the extra dependency; a Docker image built from requirements.txt which omits the lvis api package; installing the wrong/renamed lvis package from PyPI instead of the GitHub API repo.","solutions":["pip install git+https://github.com/lvis-dataset/lvis-api.git","If offline, install from a mirror or vendored wheel of lvis-api, then verify with `python -c \"import lvis\"`","Only use LVISMetric when you actually evaluate on LVIS annotations; use CocoMetric for COCO datasets"],"exampleFix":"// before\n$ python tools/test.py config.py ckpt.pth  # RuntimeError: Package lvis is not installed\n// after\n$ pip install git+https://github.com/lvis-dataset/lvis-api.git\n$ python tools/test.py config.py ckpt.pth","handlingStrategy":"validation","validationCode":"try:\n    import lvis  # noqa: F401\n    has_lvis = True\nexcept ImportError:\n    has_lvis = False\nif not has_lvis:\n    raise SystemExit('Install lvis first: pip install git+https://github.com/lvis-dataset/lvis-api.git')","typeGuard":null,"tryCatchPattern":"try:\n    from mmdet.evaluation import LVISMetric\n    evaluator = LVISMetric(ann_file=ann)\nexcept RuntimeError as e:\n    if 'lvis' in str(e):\n        subprocess.check_call([sys.executable, '-m', 'pip', 'install',\n            'git+https://github.com/lvis-dataset/lvis-api.git'])\n        evaluator = LVISMetric(ann_file=ann)\n    else:\n        raise","preventionTips":["Pre-install lvis-api in Dockerfiles used for LVIS experiments","Gate LVIS configs behind an import check in CI","Use CocoMetric for non-LVIS datasets"],"tags":["mmdetection","lvis","missing-dependency","evaluation"],"backgroundTag":"missing-optional-dependency","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}