OpenCV Python - cv2 Module not found
Question: Even though I believe I have installed correctly OpenCV, I cannot overcome the
following problem. When I start a new python project from IDLE (2.7) the cv2
module is imported successfully. If I close IDLE and try to run the .py file,
an error message is displayed that says "ImportError: No module named cv2".
Then if I create a clean project through IDLE it works until I close it. What
could be the problem?

P.S. I am using Python 2.7 and OpenCV 3.1, but tried also with 2.4.13 on
Windows 10.


Answer: Try to reinstall it by `sudo apt-get install python-opencv`, But first you may
check out something you might be skipping. Make sure the script you are
running on the terminal is on the same python version/ location as on IDLE.
Maybe your IDLE is running on a different interpreter(different location).
Open IDLE and check the path of cv2 module by `cv2.__file__`. Or you can check
the executables path by `sys.path`. Then check the executable python path by
running the script from the terminal, it must be same or else you need to
explicitly set the `PYTHONPATH` to executable path shown in IDLE.

Edit: According to the comments the problem you are facing is with the
execution path, add the idle execution path to the environment variable `path`
\- on Windows. You can do it on the go by

`SET PATH=%PATH%;c:\python27` on cmd Change the path to your context (of the
IDLE).

