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
401 views
in Technique[技术] by (71.8m points)

python - How can I upgrade NumPy?

When I installed OpenCV using Homebrew (brew), I got this problem whenever I run this command to test 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

I tried to upgrade NumPy, but this is confusing:

>>> import numpy
>>> print numpy.__version__
1.6.1

When I run brew to upgrade NumPy, I got this problem:

brew install -u numpy
Warning: numpy-1.9.1 already installed

When I uninstalled it:

sudo pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in ./anaconda/lib/python2.7/site-packages

I have followed this question and deleted Anaconda from my mac.

pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /Library/Python/2.7/site-packages

But nothing have changed. How can I link the NumPy version to OpenCV?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

When you already have an older version of NumPy, use this:

pip install numpy --upgrade

If it still doesn't work, try:

pip install numpy --upgrade --ignore-installed

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

...