{"record":{"id":"f1d16e7a2c6f7896","repo":"open-mmlab/mmdetection","slug":"mmpycocotools-is-deprecated-please-install-offici","errorCode":null,"errorMessage":"mmpycocotools is deprecated. Please install official pycocotools by \"pip install pycocotools\"","messagePattern":"mmpycocotools is deprecated\\. Please install official pycocotools by \"pip install pycocotools\"","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mmdet/datasets/api_wrappers/coco_api.py","lineNumber":22,"sourceCode":"import warnings\nfrom collections import defaultdict\nfrom typing import List, Optional, Union\n\nimport pycocotools\nfrom pycocotools.coco import COCO as _COCO\nfrom pycocotools.cocoeval import COCOeval as _COCOeval\n\n\nclass COCO(_COCO):\n    \"\"\"This class is almost the same as official pycocotools package.\n\n    It implements some snake case function aliases. So that the COCO class has\n    the same interface as LVIS class.\n    \"\"\"\n\n    def __init__(self, annotation_file=None):\n        if getattr(pycocotools, '__version__', '0') >= '12.0.2':\n            warnings.warn(\n                'mmpycocotools is deprecated. Please install official pycocotools by \"pip install pycocotools\"',  # noqa: E501\n                UserWarning)\n        super().__init__(annotation_file=annotation_file)\n        self.img_ann_map = self.imgToAnns\n        self.cat_img_map = self.catToImgs\n\n    def get_ann_ids(self, img_ids=[], cat_ids=[], area_rng=[], iscrowd=None):\n        return self.getAnnIds(img_ids, cat_ids, area_rng, iscrowd)\n\n    def get_cat_ids(self, cat_names=[], sup_names=[], cat_ids=[]):\n        return self.getCatIds(cat_names, sup_names, cat_ids)\n\n    def get_img_ids(self, img_ids=[], cat_ids=[]):\n        return self.getImgIds(img_ids, cat_ids)\n\n    def load_anns(self, ids):\n        return self.loadAnns(ids)\n","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/datasets/api_wrappers/coco_api.py#L4-L40","documentation":"Warning from the COCO api wrapper: the installed pycocotools is the deprecated 'mmpycocotools' fork (version string >= '12.0.2' heuristic), and mmdet asks you to move to official pycocotools.","triggerScenarios":"Instantiating CocoAPI/COCO while the mmpycocotools fork (which used inflated version numbers like 12.x) is installed instead of official pycocotools.","commonSituations":"Old mmdet 2.x environments or Docker images that pinned mmpycocotools; it duplicated code and drifted from upstream.","solutions":["pip uninstall mmpycocotools && pip install pycocotools","Recreate the environment from updated mmdet requirements"],"exampleFix":"# before\npip install mmpycocotools\n# after\npip uninstall mmpycocotools\npip install pycocotools","handlingStrategy":"validation","validationCode":"import pycocotools\nver = getattr(pycocotools, '__version__', '0')\nif ver >= '12.0.2':\n    print('deprecated mmpycocotools detected; switch to official pycocotools')","typeGuard":null,"tryCatchPattern":"import warnings\nwith warnings.catch_warnings():\n    warnings.filterwarnings('ignore', message='mmpycocotools is deprecated')\n    from mmdet.datasets.api_wrappers.coco_api import CocoAPI","preventionTips":["Pin official pycocotools in requirements","Avoid legacy mmdet 2.x docker images for new work"],"tags":["python","warning","pycocotools","deprecated-dependency","coco"],"backgroundTag":"deprecated-package-fork","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}