简体   繁体   English

2.7的python opencv导入错误

[英]python opencv import error for 2.7

I tried to import the cv2 package in windows and I got the error: 我试图在Windows中导入cv2软件包,但出现错误:

>>> import numpy
>>> numpy.version.version
'1.6.1'
>>> import cv2
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x6

Traceback (most recent call last): File "", line 1, in import cv2 ImportError: numpy.core.multiarray failed to import 追溯(最近一次呼叫最近):导入cv2 ImportError中的文件“”,第1行:numpy.core.multiarray导入失败

I have also tried numpy verson 1.11.1 but it didn't work. 我也尝试了numpy verson 1.11.1,但是没有用。

You should ensure that you have a single version of numpy installed, assuming you are not working within a virtualenv . 假设您不在virtualenv工作,则应确保安装了numpy的单个版本。 Python may still be loading the old numpy package. Python可能仍在加载旧的numpy包。 If that is the case, you will need to remove the old version, or, to make things easier in the long run, use a virtualenv with only the packages you require. 在这种情况下,您将需要删除旧版本,或者从长远来看,为了使事情变得更轻松,请仅将virtualenv与所需的软件包一起使用。

You can check the numpy path: 您可以检查numpy路径:

import numpy
print numpy.__path__

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM