How this occurred: I wrote import cv2
in jupyter notebook code cell and run,then ImportError
occurred.
What I have tried: I have tried to uninstall opencv-python
and opencv-contrib-python
and reinstall opencv-python
, but it didn't work.
Detailed Error:
ImportError Traceback (most recent call last)
<ipython-input-1-7660ed0d4d71> in <module>
----> 1 import cv2
2 import numpy as np
3 import os
4 from matplotlib import pyplot as plt
5 import time
D:\Anaconda3\lib\site-packages\cv2\__init__.py in <module>
7
8 from .cv2 import *
----> 9 from .cv2 import _registerMatType
10 from . import mat_wrapper
11 from . import gapi
ImportError: cannot import name '_registerMatType' from 'cv2.cv2' (D:\Anaconda3\lib\site-packages\cv2\cv2.cp38-win_amd64.pyd)
As you have reinstalled opencv-python
, I believe you have the latest version, 4.5.5.62
.
Simply make sure that you have the corresponding version of opencv-python-headless
, which is also the latest version, 4.5.5.62
. If your opencv-python-headless
is not the latest version, I recommend you uninstalling it, and then reinstalling it.