ImportError: No module named cv2 solution
method one:
After installing opencv, when you run the files under samples, it may happen that the cv2 module cannot be found.
In fact, there is a way that you don't need to change it is that you first enter the virtual changer of cv before running the samples.
workon cv
- 1
Then run it again and you can run it successfully.
Method Two:
Someone on the stackoverflow site said this:
This is because you are missing a module, just install this module and
I was successful after installing this module.
sudo apt-get install python-opencv
- 1
If some software packages fail to install during the module installation process, just update the software again:
sudo apt-get update
- 1
Method three:
Copy the cv2.pyd in the Python folder in the OpenCV installation directory to the site-packages in the Lib in the python installation directory to solve the problem.
Recently, someone told me that the above method was unsuccessful. I tested it myself, and it did happen. My solution was to install libopev-dev and it worked!