question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pycocotools.COCO couldn't be loaded

See original GitHub issue

I followed through the steps in GETTING_STARTED.md to set up in conda. All the requirements were installed successfully. However, when verifying mmskeleton and mmdetection using python mmskl.py pose_demo [--gpus $GPUS], I encountered the following error:

(mmskeleton) thtang@thtang-X299-A:~/Code/mmskeleton$ python mmskl.py pose_demo
/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/site-packages/Cython/Distutils/old_build_ext.py:41: UserWarning: Cython.Distutils.old_build_ext does not properly handle dependencies and is deprecated.
  "Cython.Distutils.old_build_ext does not properly handle dependencies "
Traceback (most recent call last):
  File "mmskl.py", line 7, in <module>
    import mmskeleton
  File "/home/thtang/Code/mmskeleton/mmskeleton/__init__.py", line 1, in <module>
    from . import utils
  File "/home/thtang/Code/mmskeleton/mmskeleton/utils/__init__.py", line 3, in <module>
    from .checkpoint import load_checkpoint, get_mmskeleton_url, cache_checkpoint
  File "/home/thtang/Code/mmskeleton/mmskeleton/utils/checkpoint.py", line 1, in <module>
    from mmcv.runner import load_checkpoint as mmcv_load_checkpoint
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/site-packages/mmcv-1.3.5-py3.7.egg/mmcv/runner/__init__.py", line 3, in <module>
    from .base_runner import BaseRunner
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/site-packages/mmcv-1.3.5-py3.7.egg/mmcv/runner/base_runner.py", line 12, in <module>
    from ..parallel import is_module_wrapper
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/site-packages/mmcv-1.3.5-py3.7.egg/mmcv/parallel/__init__.py", line 6, in <module>
    from .registry import MODULE_WRAPPERS
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/site-packages/mmcv-1.3.5-py3.7.egg/mmcv/parallel/registry.py", line 5, in <module>
    MODULE_WRAPPERS = Registry('module wrapper')
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/site-packages/mmcv-1.3.5-py3.7.egg/mmcv/utils/registry.py", line 90, in __init__
    self._scope = self.infer_scope() if scope is None else scope
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/site-packages/mmcv-1.3.5-py3.7.egg/mmcv/utils/registry.py", line 142, in infer_scope
    filename = inspect.getmodule(inspect.stack()[2][0]).__name__
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/inspect.py", line 1513, in stack
    return getouterframes(sys._getframe(1), context)
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/inspect.py", line 1490, in getouterframes
    frameinfo = (frame,) + getframeinfo(frame, context)
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/inspect.py", line 1464, in getframeinfo
    lines, lnum = findsource(frame)
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/inspect.py", line 780, in findsource
    module = getmodule(object, file)
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/inspect.py", line 733, in getmodule
    if ismodule(module) and hasattr(module, '__file__'):
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/site-packages/lazy_import-0.2.2-py3.7.egg/lazy_import/__init__.py", line 156, in __getattribute__
    _load_module(self)
  File "/home/thtang/anaconda3/envs/mmskeleton/lib/python3.7/site-packages/lazy_import-0.2.2-py3.7.egg/lazy_import/__init__.py", line 537, in _load_module
    msg.format(**modclass._lazy_import_error_strings)), None)
  File "<string>", line 3, in raise_from
ImportError: mmskeleton.utils.third_party attempted to use a functionality that requires module pycocotools.COCO, but it couldn't be loaded. Please install pycocotools and retry.

I have tried installing pycocotools using options here, but the same error still occurred.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

14reactions
zhengthomastangcommented, May 29, 2021

Found the error. Need to correct this line in coco.py:

from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval

Also need to correct these in third_party.py:

COCO = lazy_import.lazy_module("pycocotools.coco.COCO")
COCOeval = lazy_import.lazy_module("pycocotools.cocoeval.COCOeval")
3reactions
Donny2333commented, May 29, 2021

Maybe you could have a try to install mmcv==0.4.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

COCO python API is installed but can't import it - Stack Overflow
For that I want an image dataset from COCO to be imported; for which I have installed pycocotools API. But when I'm trying...
Read more >
DICOM RLE Support in Slicer
A possible data flow would be: Load each image from DICOM into 3D Slicer, segment it, and save both the image and segmentation...
Read more >
Detectron2 Car Damaged Parts Detection - Kaggle
Detectron2 is a PyTorch based modular object detection library · Load trained model · Damage Detection Model · Parts Segmentation Model · Model...
Read more >
Inspecting COCO Dataset Using COCO API - Lei Mao
COCO Dataset Exploration. ... loading, annotating, and saving images, have been created. explore_coco. ... from pycocotools.coco import COCO
Read more >
coco - Bountysource
I tried to install pycocotools with the command pip install pycocotools, ... out a few days ago but I couldn't quite figure out...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found