ImportError: numpy.core.multiarray failed to import

user3090952 picture user3090952 · Dec 11, 2013 · Viewed 296.5k times · Source

I'm trying to run this program

import cv2
import time

cv.NamedWindow("camera", 1)

capture = cv.CaptureFromCAM(0)

while True:
    img = cv.QueryFrame(capture)
    cv.ShowImage("camera", img)
    if cv.WaitKey(10) == 27:
        break
cv.DestroyAllWindows()

But I'm having a problem with numpy, I'm using pyschopy along with opencv. The problem I keep getting is this error report:

RuntimeError: module compiled against API version 7 but this version of numpy is 6

Traceback (most recent call last):

File "C:\Users\John\Documents\EyeTracking\Programs\GetImage.py", line 1, in

import cv2

ImportError: numpy.core.multiarray failed to import

I have numpy-1.6.1-py2.7 in the psychopy folder, I'm just confused as to what is wrong?

Edit (Deleted Answer)

The following command

pip install -U numpy 

helps solving the problem: could not load numpy.core.multiarray.

Answer

David Ketcheson picture David Ketcheson · Feb 21, 2014

I was getting the same error and was able to solve it by updating my numpy installation to 1.8.0:

pip install -U numpy