OpenCV install: deprecation error - python

I would like to use opencv with python, but I think I have a problem with my numpy version.
How can I make sure that opencv uses the right numpy version?
I did
sudo pip install opencv-python
And I received this message
Installing collected packages: numpy, opencv-python
Found existing installation: numpy 1.8.0rc1
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling numpy-1.8.0rc1:
Successfully uninstalled numpy-1.8.0rc1
Successfully installed numpy-1.14.5 opencv-python-3.4.1.15
Now when I try
import cv2
I get
ImportError: numpy.core.multiarray failed to import
I also updated my numpy version with
sudo pip install -U numpy

If you are using both Py2.7 and 3.5 on your machine, make sure numpy is being installed for the correct version by doing either python3 -m pip install numpy -I
or python2 -m pip install numpy -I

Related

ImportError: numpy.core.multiarray failed to import (cv2)

I tried 3 versions of python and deferent versions of Numpy, OpenCv-Python and I still become the same error
I fixed this issue by uninstalling numpy
pip uninstall numpy
and after installing the previous version of numpy
python -m pip install numpy==1.19.3

Numpy: import error for python2.7 after get-apt upgrade

Today, I have decided to upgrade my software packages:
sudo apt-get upgrade
After that, I am trying to launch my python2 code and the error appears:
ImportError: No module named numpy
I have tried pip install numpy, but got a message
Requirement already satisfied: numpy in /home/user/anaconda3/lib/python3.5/site-packages (1.15.1)
pip2 install numpy produces an exception:
pkg_resources.VersionConflict: (pip 18.0 (/usr/local/lib/python3.5/dist-packages), Requirement.parse('pip==8.1.1'))
conda install numpy results in
# All requested packages already installed.
which python gives me
/home/user/anaconda3/bin/python
which pip results in
/home/user/anaconda3/bin/pip
What could be the problem? Seems like numpy cannot be installed for python2 because it is already installed for python3. I suppose, something went wrong with python2 vs python3 linkage in conda? Is it a problem with python, numpy, pip, conda or environments?

how to install openCV_python with no import cv2 error?

I am trying to install the OpenCV-python on my mac and i have used the following:
$pip install opencv-python
which gave me the following error:
$pip install opencv-python
Collecting opencv-python
Using cached opencv_python-3.4.0.12-cp27-cp27m macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting numpy>=1.11.1 (from opencv-python)
Using cached numpy-1.14.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
Installing collected packages: numpy, opencv-python
Found existing installation: numpy 1.8.0rc1
Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Then i did try the pip install --upgrade matplotlib which didnot change anything. It just show me:
matplotlib 2.2.2 requires backports.functools-lru-cache, which is not installed.
matplotlib 2.2.2 has requirement numpy>=1.7.1, but you'll have numpy 1.8.0rc1 which is incompatible.
As I found many ways to install the openCV-python in the internet like:
https://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/
and I installed on my other mac but i got import cv2 problem alot in my codes.
I will be more than happy if anyone have a good solution or recommendation to install the openCV-python.
Thanks
In summary, macOS comes with the Python preinstalled and you should not mess with the packages installed as some system utilities depend on them.
https://docs.python.org/3.7/using/mac.html
The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do.
You should take a look on either venv or virtualenv.
You can read this answer: https://stackoverflow.com/a/41972262/4796844 that will get you through the basics.
In a nutshell, to solve your problem:
$ python3 -m venv ./project-name
$ . ./project-name/bin/activate
$ pip install opencv-python
And to leave the virtual environment, simply:
$ deactivate

Cannot pip install sklearn for Python 3.6

First, I downloaded the numpy+nlk whl file here and did
python3 -m pip install numpy‑1.11.3+mkl‑cp36‑none-any.whl
I renamed thanks to this tip: filename.whl is not supported wheel on this platform
But when I do
python3 -m pip install sklearn
I get Original error was: cannot import name 'multiarray'
I've tried unistalling and reinstalling numpy, but I have no idea how to fix this.
I just uploaded the windows wheels for scikit-learn 0.18.2 and Python 3.6 to PyPi: https://pypi.python.org/pypi/scikit-learn/0.18.2 Can you try again and give the full traceback if that still does not work?
If you have installed pip then follow the given steps:
upgrade pip to the latest version
install
pip install numpy scipy scikit-learn
pip install sklearn

How to install Numpy & Scipy for Python 3.3 on Moutain Lion

Haven't found a working solution as of yet. I have three different versions of Python on my system, the default bundled with OSX (2.7.2), 2.7.3 installed via homebrew and 3.3.0 installed via homebrew. Running pip install numpy or pip install scipy will install it for the 2.7.3 version.
How can I install numpy and scipy for Python 3.3.0 on Moutain Lion?
you need to call pip3 instead of pip. Homebrew installs pip3 with python3.
I just tried pip3 install numpy on my OSX 10.7.5 python 3.3.0 machine and it failed. It looks like numpy v1.6 is not compatible but numpy v1.7 (beta, not available via pip3) is.
Link: A post on SO:
Why does installing numpy using pip fail while building directly does not

Categories