Importing opencv and getting numpy.core.multiarray failed to import

I had a similar problem and I solved it by downgrading my numpy version.

What I did was:

pip install opencv-python
pip uninstall numpy
pip install numpy=1.18

This has worked for me using

Python 3.7 opencv-python 4.4.0.46 numpy 1.18.0


The error is telling you that you have an out of date version of numpy. If you used pip to install things you can simply run pip install numpy -U, or download the appropriate version from their website.


In case

pip install -U numpy

doesn't work (even with sudo), you may want to make sure you're using the right version of numpy. I had the same "numpy.core.multiarray failed to import" issue, but it was because I had 1.6 installed for the version of Python I was using, even though I kept installing 1.8 and assumed it was installing in the right directory.

I found the bad numpy version by using the following command in my Mac terminal:

python -c "import numpy;print numpy.version;print numpy.file";

This command gave me the version and location of numpy that I was using (turned out it was 1.6.2). I went to this location and manually replaced it with the numpy folder for 1.8, which resolved my "numpy.core.multiarray failed to import" issue. Hopefully someone finds this useful!