{"record":{"id":"dae11e5d7a92d3dc","repo":"open-mmlab/mmdetection","slug":"please-run-pip-install-jsonlines-to-install-this","errorCode":null,"errorMessage":"Please run \"pip install jsonlines\" to install this package.","messagePattern":"Please run \"pip install jsonlines\" to install this package\\.","errorType":"validation","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"mmdet/evaluation/metrics/dump_odvg_results.py","lineNumber":34,"sourceCode":"@METRICS.register_module()\nclass DumpODVGResults(BaseMetric):\n    default_prefix: Optional[str] = 'pl_odvg'\n\n    def __init__(self,\n                 outfile_path,\n                 img_prefix: str,\n                 score_thr: float = 0.1,\n                 collect_device: str = 'cpu',\n                 nms_thr: float = 0.5,\n                 prefix: Optional[str] = None) -> None:\n        super().__init__(collect_device=collect_device, prefix=prefix)\n        self.outfile_path = outfile_path\n        self.score_thr = score_thr\n        self.img_prefix = img_prefix\n        self.nms_thr = nms_thr\n\n        if jsonlines is None:\n            raise ImportError('Please run \"pip install jsonlines\" to install '\n                              'this package.')\n\n    def process(self, data_batch: Any, data_samples: Sequence[dict]) -> None:\n        for data_sample in data_samples:\n            result = {}\n\n            filename = data_sample['img_path']\n            filename = filename.replace(self.img_prefix, '')\n            if filename.startswith('/'):\n                filename = filename[1:]\n            result['filename'] = filename\n\n            height = data_sample['ori_shape'][0]\n            width = data_sample['ori_shape'][1]\n            result['height'] = height\n            result['width'] = width\n\n            pred_instances = data_sample['pred_instances']","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/evaluation/metrics/dump_odvg_results.py#L16-L52","documentation":"DumpODVGResultsMetric.__init__ needs the `jsonlines` package to write results in the ODVG (object detection / visual grounding) jsonl format, and it guards the import — if jsonlines is None it raises ImportError telling you to pip install it. The metric is used to dump detections to .jsonl for grounding/VLM pipelines and cannot run without the writer.","triggerScenarios":"Constructing DumpODVGResultsMetric in an env where `import jsonlines` failed; running configs for ODVG-style training data generation (e.g.蒸馏/grounding data dumps) on a base mmdet install that lacks the optional dependency.","commonSituations":"Fresh install from mmdet requirements (jsonlines is not included); new conda/docker env; CI running a dump job for the first time.","solutions":["pip install jsonlines","Verify in the training env: python -c \"import jsonlines\"","Add jsonlines to your environment/Dockerfile requirements if you use ODVG dumping"],"exampleFix":"# before: ImportError in DumpODVGResultsMetric(...)\n# after\npip install jsonlines\npython -c 'import jsonlines; print(jsonlines.__version__)'","handlingStrategy":"validation","validationCode":"try:\n    import jsonlines  # noqa\n    jsonlines_ok = True\nexcept ImportError:\n    jsonlines_ok = False\nassert jsonlines_ok, 'pip install jsonlines before using DumpODVGResultsMetric'","typeGuard":"def odvg_dump_available() -> bool:\n    try:\n        import jsonlines  # noqa: F401\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"try:\n    DumpODVGResultsMetric(...)\nexcept ImportError as e:\n    if 'jsonlines' in str(e):\n        subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'jsonlines'])\n        DumpODVGResultsMetric(...)\n    else:\n        raise","preventionTips":["Add jsonlines to requirements if any config uses DumpODVGResultsMetric","Fail fast on missing optional deps at job start, not at eval time","Cache a wheel of jsonlines in air-gapped CI environments"],"tags":["mmdetection","odvg","missing-dependency","pip","jsonl"],"backgroundTag":"missing-python-package","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}