一 .环境信息
win10/64bit anaconda3 python 3.5.4 opencv3
二.报错信息
创建了一个新的conda环境,在环境中配置了TensorFlow和Keras.
使用pip install [file path]
的方式安装
opencv_python 3.4.0+contrib cp35 cp35m win_amd64.whl 文件
安装完成后,python下import cv2
失败,报错如下
RuntimeError: module compiled against API version 0xb but this version
of numpy is 0xa
Traceback (most recent call last):
File “”, line 1, in
ImportError: numpy.core.multiarray failed to import
三.问题解决
问题出在系统中有两个版本的numpy
之前anaconda的root环境中,安装的是1.13.1
在新创建的环境中,安装的是1.12.1,版本低了,和openCV 对不上
使用
pip install numpy --upgrade
升级到了 1.14.1
再次import cv2
就没问题了
四.问题总结
这个问题的出现和我配置环境时使用的
conda create -n [ENV_NAME] --file spec-file.txt
这种方式有关系。在 txt 文件里写着所有的依赖包,配置时按照txt里的顺序安装,可能出现不符合依赖关系的安装。
更多的讨论可以参考
Stackoverflow