当我使用 Homebrew 安装 OpenCV 时(brew
),每当我运行这个命令来测试 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
我关注了this question并删除了Anaconda从我的 mac。
pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /Library/Python/2.7/site-packages
但一切都没有改变。如何将 NumPy 版本链接到 OpenCV?
最佳答案
如果您已经拥有旧版本的 NumPy,请使用:
pip install numpy --upgrade
如果还是不行,试试:
pip install numpy --upgrade --ignore-installed
关于python - 如何升级 NumPy?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28517937/