import cv2 error:ImportError: numpy.core.multiarray failed to import

created at 06-26-2021 views: 7

System environment: Windows10
Python environment: Anaconda + Python3.6.3
OpenCV: 3.4.3
After installing the OpenCV library, the problem of numpy.core.multiarray failed to import occurs when importing cv2:

(D:\Users\XXX\Anaconda3) C:\Users\XXX>python
Python 3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import

Problem: OpenCV3 version does not match the version of Numpy, you can try to update the number of NUMPYs to try. Solution: Enter: Enter: in the console window:

Solution:
Enter in the console window:

pip install -U numpy

The following information appears indicates that the downgrade is completed.

(D:\Users\XXX\Anaconda3) C:\Users\XXX>pip install -U numpy
Collecting numpy
  Downloading https://files.pythonhosted.org/packages/51/70/7096a735b27359dbc0c380b23b9c9bd05fea62233f95849c43a6b02c5f40/numpy-1.15.4-cp36-none-win_amd64.whl (13.5MB)
    100% |████████████████████████████████| 13.5MB 27kB/s
Installing collected packages: numpy
  Found existing installation: numpy 1.12.0
    Uninstalling numpy-1.12.0:
      Successfully uninstalled numpy-1.12.0
Successfully installed numpy-1.15.4

Test again, import successfully! 

(D:\Users\XXX\Anaconda3) C:\Users\XXX>python
Python 3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
created at:06-26-2021
edited at: 06-26-2021: