opencv is not compatible with python 3. I had to install opencv3 for python 3. The marked answer in how could we install opencv on anaconda? explains how to install opencv(3) for anaconda:
Answer from Linda on Stack OverflowRun the following command:
conda install -c https://conda.binstar.org/menpo opencvI realized that opencv3 is also available now, run the following command:
conda install -c https://conda.binstar.org/menpo opencv3Edit on Aug 18, 2016: You may like to add the "menpo" channel permanently by:
conda config --add channels menpoAnd then opencv can be installed by:
conda install opencv (or opencv3)Edit on Aug 14, 2017: "clinicalgraphics" channel provides relatively newer vtk version for very recent python3
conda install -c clinicalgraphics vtkEdit on April 16, 2020 (based on @AMC's comment): OpenCV can be installed through
conda-forge(details see here)
conda install -c conda-forge opencv
opencv is not compatible with python 3. I had to install opencv3 for python 3. The marked answer in how could we install opencv on anaconda? explains how to install opencv(3) for anaconda:
Run the following command:
conda install -c https://conda.binstar.org/menpo opencvI realized that opencv3 is also available now, run the following command:
conda install -c https://conda.binstar.org/menpo opencv3Edit on Aug 18, 2016: You may like to add the "menpo" channel permanently by:
conda config --add channels menpoAnd then opencv can be installed by:
conda install opencv (or opencv3)Edit on Aug 14, 2017: "clinicalgraphics" channel provides relatively newer vtk version for very recent python3
conda install -c clinicalgraphics vtkEdit on April 16, 2020 (based on @AMC's comment): OpenCV can be installed through
conda-forge(details see here)
conda install -c conda-forge opencv
Use this code at the Anaconda prompt:
Copyconda update conda -c conda-canary
Then don't type this code:
Copyconda install -c conda-forge opencv
but, instead, use:
CopyPip install opencv-python
It worked with me after few days of trials
See Krishna Ojha's video and read the comments below the video.
Issue "ModuleNotFoundError: No module named 'cv2'" although opencv is installed
python - No module named 'cv2' on Anaconda 3.8.3 - Stack Overflow
python - Cannot find module cv2 when using OpenCV - Stack Overflow
ModuleNotFoundError: No module named 'cv2'
Videos
Just open your command prompt with run as administrator. And try,
conda install -c conda-forge opencv
I was getting this error when using the command conda install -c menpo opencv
Specifications:
- opencv -> python[version='2.7.*|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0'] Your python: python=3.8 .So,by using pip it got solved.
pip install opencv-contrib-python
First do run these commands inside Terminal/CMD:
conda update anaconda-navigator
conda update navigator-updater
Then the issue for the instruction below will be resolved
For windows if you have anaconda installed, you can simply do
pip install opencv-python
or
conda install -c https://conda.binstar.org/menpo opencv
if you are on linux you can do :
pip install opencv-python
or
conda install opencv
Link1 Link2
For python3.5+ check these links : Link3 , Link4
Update:
if you use anaconda, you may simply use this as well (and hence don't need to add menpo channel):
conda install -c conda-forge opencv
This happens when python cannot refer to your default site-packages folder where you have kept the required python files or libraries
Add these lines in the code:
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages')
or before running the python command in bash move to /usr/local/lib/python2.7/site-packages directory. This is a work around if you don't want to add any thing to the code.