When I installed OpenCV using Homebrew (brew
), I got this problem whenever I run this command to test python -c \"import cv2\"
:
Run
Because we have two NumPy installations in the system. One is installed by Homebrew and the second is installed by pip. So in order to solve the problem, we need to delete one and use the default NumPy install by OpenCV.
Check the path,
import numpy
print numpy.__path__
and manually delete it using rm
.
I tried doing sudo pip uninstall numpy
instead, because the rm
didn't work at first.
Hopefully that helps.
Uninstalling then to install it again.
If you don't encounter any permission errors with
pip install -U numpy
try:
pip install --user -U numpy
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
If you are stuck with a machine where you don't have root access, then it is better to deal with a custom Python installation.
The Anaconda installation worked like a charm:
After installation,
[bash]$ /xxx/devTools/python/anaconda/bin/pip list --format=columns | grep numpy
numpy 1.13.3 numpydoc 0.7.0
Because you have multiple versions of NumPy installed.
Try pip uninstall numpy
and pip list | grep numpy
several times, until you see no output from pip list | grep numpy
.
Then pip install numpy
will get you the newest version of NumPy.