Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
643 views
in Technique[技术] by (71.8m points)

python - ImportError: numpy.core.multiarray failed to import

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:UsersJohnDocumentsEyeTrackingProgramsGetImage.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.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...