最佳答案
当我使用 自酿的(brew
)安装 OpenCV 时,每当我运行这个命令来测试 python -c "import cv2"
时都会遇到这个问题:
RuntimeError: module compiled against API version 9 but this version of numpy is 6
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import
我试过升级 NumPy,但这让我很困惑:
>>> import numpy
>>> print numpy.__version__
1.6.1
当我运行 brew 来升级 NumPy 时,我遇到了这个问题:
brew install -u numpy
Warning: numpy-1.9.1 already installed
当我卸载它的时候:
sudo pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in ./anaconda/lib/python2.7/site-packages
pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /Library/Python/2.7/site-packages
但是一切都没有改变,我怎样才能将 NumPy 版本链接到 OpenCV 呢?