close

[Solved] Anaconda: cannot import cv2 even though opencv is installed (how to install opencv3 for python3)

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Anaconda: cannot import cv2 even though opencv is installed (how to install opencv3 for python3) in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Anaconda: cannot import cv2 even though opencv is installed (how to install opencv3 for python3) Error Occurs?

Today I get the following error Anaconda: cannot import cv2 even though opencv is installed (how to install opencv3 for python3) in python.

How To Solve Anaconda: cannot import cv2 even though opencv is installed (how to install opencv3 for python3) Error ?

  1. How To Solve Anaconda: cannot import cv2 even though opencv is installed (how to install opencv3 for python3) Error ?

    To Solve Anaconda: cannot import cv2 even though opencv is installed (how to install opencv3 for python3) Error I had created my Anaconda environment and installed everything I needed, but when trying to import cv2, I always got the message “no module named cv2”. I reinstalled and followed Linda's tips, which didn't work.

  2. Anaconda: cannot import cv2 even though opencv is installed (how to install opencv3 for python3)

    To Solve Anaconda: cannot import cv2 even though opencv is installed (how to install opencv3 for python3) Error I had created my Anaconda environment and installed everything I needed, but when trying to import cv2, I always got the message “no module named cv2”. I reinstalled and followed Linda's tips, which didn't work.

Solution 1

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 opencv

I realized that opencv3 is also available now, run the following command:

conda install -c https://conda.binstar.org/menpo opencv3

Edit on Aug 18, 2016: You may like to add the “menpo” channel permanently by:

conda config --add channels menpo

And 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 vtk

Edit 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

Solution 2

I had created my Anaconda environment and installed everything I needed, but when trying to import cv2, I always got the message “no module named cv2”. I reinstalled and followed Linda’s tips, which didn’t work.

Finally, I noticed that my Anaconda environment didn’t have cv2 installed, even with all I did.
I copied the cv2 folder to “miniconda’X’/envs/yourEnv/lib/python’X.X’/site-packages/” which worked for me.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read