. Advertisement .
..3..
. Advertisement .
..4..
The error: “ImportError: cannot import name ‘_registerMatType’ from ‘cv2.cv2’” is a common error that can show up in many ways. In this blog, we will go through some of the ways you can fix this issue. Read on.
When dose this error happen?
There are some steps that you found this error, like you try to utilize the Object Detection API, or when you use Colab. A possible cause may be that the opencv-python(4.1.2.30) version does not fit with opencv-python-headless(4.5.5.62). Moreover, the latest version 4.5.5 may get the wrong thing. Thus, you found the following problem.
ImportError: cannot import name '_registerMatType' from 'cv2.cv2'
How To Solve The Error: “ImportError: cannot import name ‘_registerMatType’ from ‘cv2.cv2’”?
To solve this problem there are many ways but we will provide the best solutions to correct it effectively and hope it help if you face with the issue: ImportError: cannot import name ‘_registerMatType’ from ‘cv2.cv2
Approach 1: Downgrade opencv-python-headless
This error happens since opencv-python(4.1.2.30) does not match opencv-python-headless latest version.
So, to begin with, utilize the following command to uninstall opencv-python-headless:
pip uninstall opencv-python-headless
Install opencv-python-headless==4.1.2.30 with this command:
pip install opencv-python-headless==4.1.2.30
Approach 2: Using docker
For the problem on docker, you should use version 4.3.0.38
. Then, install the package with
conda install -c conda-forge opencv=4.3.0
Now, you have solved your problem.
Conclusion
We hope you enjoyed our article about the error. With this knowledge, we know that you can fix your error: “ImportError: cannot import name ‘_registerMatType’ from ‘cv2.cv2’” quickly by following these steps! If you still have any other questions about fixing this syntax error, please leave a comment below. Thank you for reading!
Leave a comment