close

[Solved] ImportError: No module named cv2 Cannot find module cv2 when using OpenCV

Hello Guys, How are you all? Hope You all Are Fine. I have installed openCV and when I try to import cv2 I get the following error ImportError: No module named cv2 Cannot find module cv2 when using OpenCV in Python. So Here I am Explain to you all the possible solutions here.

Without Wasting your time, Lets start This Article to Solve This Error.

How This ImportError: No module named cv2 Cannot find module cv2 when using OpenCV Error Occurs ?

I have installed openCV and when I try to import cv2 I get the following error:

Traceback (most recent call last)
File "cam.py", line 1, in <module>
    import cv2
ImportError: No module named cv2

How To Solve ImportError: No module named cv2 Cannot find module cv2 when using OpenCV Error ?

Question: How To Solve ImportError: No module named cv2 Cannot find module cv2 when using OpenCV Error?
Answer: This error may occur if you didn’t install opencv module in your system. To Solve ImportError: No module named cv2 Cannot find module cv2 when using OpenCV just follow all step below to install openCV.

Solution 1

This error may occur if you didn’t install opencv module in your system. To Solve ImportError: No module named cv2 Cannot find module cv2 when using OpenCV just follow all step below to install openCV.

  1. First of all update anaconda-navigator and navigator-updater by run this command in your terminal.
    1. conda update anaconda-navigator
    2. conda update navigator-updater
  2. For windows, if you have Anaconda installed, you can simply do
    1. pip install opencv-python
    2. OR conda install -c https://conda.binstar.org/menpo opencv
  3. if you are on linux you can do :
    1. pip install opencv-python
    2. OR conda install opencv
  4. Now you can use cv2 without error.

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

Solution 2

This command solved this issue

conda install opencv

Solution 3

Python3.x User

sudo pip3 install opencv-python

Solution 4

For Those who use Windows 10 and Python 3.6, this command worked for me

pip install opencv-contrib-python

Solution 5

This will definately works fine.

pip install opencv-python

or

pip install opencv-python3 

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

Leave a Comment