Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
–
–
Your screenshot shows you doing a
pip install
from the python terminal which is wrong. Do that outside the python terminal. Also the package I believe you want is:
pip install opencv-python
Since you're running on Windows, I might look at the official install manual: https://breakthrough.github.io/Installing-OpenCV
opencv2 is ONLY compatible with Python3 if you do so by compiling the source code. See the section under opencv supported python versions: https://pypi.org/project/opencv-python
–
–
–
There is a problem with pylint, which I do not completely understood yet.
You can just import OpenCV with:
from cv2 import cv2
Please check your python version. Mine is 3.7.3 on a Mac macOS Catalina Version 10.15.7
.
If you are using Jupyter notebook,
pip3 install opencv-python
is enough.
In your notebook menu click on Kernel and hit restart. Please see the image I included.
Kernel>Restart
Then run your code again. In my case that solved the problem.
First check your python version, for example 3.10 then you can run this command to check opencv status
python3.10 -m pip show opencv-python
If not installed then install like this,
python3.10 -m pip install opencv-python
Make sure your IDE is using the correct version of Python
For example, In VSCode, you can press CTRL + Shift + P or (⌘ + Shift + P on Mac) to open the command palette.
Then type "Python select interpreter" in the field and select correct version of python.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.