Cannot find module cv2 when using OpenCV

Created by HosseinLinked to 83.3m issues across 264 teams

tl;dr

Here's how to install OpenCV on your computer:

If you have Anaconda installed, you can use the following commands in the Terminal/CMD:

conda update anaconda-navigator conda update navigator-updater

For Windows users, you can then use either of the following commands to install OpenCV:

pip install opencv-python

Or, alteratively:

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

For Linux users, you can use either of the following commands to install OpenCV:

pip install opencv-python

Or, alternatively:

conda install opencv

For Python 3.5+ users, you can refer to the following links:

  1. https://stackoverflow.com/questions/35466429/opencv-for-python-3-5-1/42540015#42540015
  2. https://stackoverflow.com/questions/26489867/opencv-for-python-3-x-under-windows/30686903#30686903

If you are using Anaconda, you can also use the following simple command to install OpenCV:

`conda install -c conda-forge opencv`