cannot import name ‘_registerMatType’ from ‘cv2.cv2’


I got below error message when I run on Object Detection API:

Traceback (most recent call last):
  File "/content/models/research/object_detection/", line 32, in <module>
    from object_detection import model_lib_v2
  File "/usr/local/lib/python3.7/dist-packages/object_detection/", line 29, in <module>
    from object_detection import eval_util
  File "/usr/local/lib/python3.7/dist-packages/object_detection/", line 36, in <module>
    from object_detection.metrics import lvis_evaluation
  File "/usr/local/lib/python3.7/dist-packages/object_detection/metrics/", line 23, in <module>
    from lvis import results as lvis_results
  File "/usr/local/lib/python3.7/dist-packages/lvis/", line 5, in <module>
    from lvis.vis import LVISVis
  File "/usr/local/lib/python3.7/dist-packages/lvis/", line 1, in <module>
    import cv2
  File "/usr/local/lib/python3.7/dist-packages/cv2/", line 9, in <module>
    from .cv2 import _registerMatType
ImportError: cannot import name '_registerMatType' from 'cv2.cv2' (/usr/local/lib/python3.7/dist-packages/cv2/

The weird thing is I run the same code before, it worked well but now it gives me an error.


The same thing occurred to me yesterday when I used Colab. A possible reason may be that the version of opencv-python( does not match opencv-python-headless( Or the latest version 4.5.5 may have something wrong…

I uninstalled opencv-python-headless== and installed and it fixed.


Leave a Reply

Your email address will not be published. Required fields are marked *