Modulenotfounderror: No Module Named: Opencv
Solution 1:
I reproduced your error and was able to fix it as following:
This error often happens when you did not added your Python path correctly.
To check wether your python is installed an configured correctly go to your terminal and type:
python -V
and then:
pip -v
The two versions have to match.
Also simply run:
python
and check wether an interactive shell opens.
If your versions are matching and the the python
command works, your python is configured correctly and you can skip the next step. If not follow the steps below, if everthing works skip this:
For Windows try this: https://superuser.com/questions/143119/how-do-i-add-python-to-the-windows-path
For Mac OS try this:
export PATH=~/path/to/your/python/bin:$PATH
For example:
export PATH=~/anaconda2/bin:$PATH
Now the next thing...
CV2 has two prerequisites there for run:
pip install matplotlib
pip install numpy
and finally:
pip install opencv-python
Now you are ready to go an you can import opencv in your code as following:
import cv2
When you are using pyhton3 use:
python3 test.py
to run your code.
If you want to use python
instead of python3
do this:
The last Python you install that registers itself in the environment is the default.
If you would like to have Python 3.x as a default version, then you will need to create environment variable 'PY_PYTHON' and set it's value to 3
Post a Comment for "Modulenotfounderror: No Module Named: Opencv"