Felicio Pedro
Felicio Pedro

Reputation: 33

ModuleNotFoundError: No module named 'cv2' in VS code

im trying to run this

import cv2
import numpy as np
import os
from matplotlib import plypot as plt
import time 
import mediapipe as mp

and also

cap = cv2.VideoCapture(0)
while cap.isOpened():

    #Reads feed
    ret, frame = cap.read()
    cv2.inshow('OpenCV feed', frame)
   
    #breaks for a while
    if cv2.waitKey(10) & 0xFF == ord('q'):

        break
    cap.release()
    cv2.destroyAllWindows()

in vscode the first one gives me ModuleNotFoundError: No module named 'cv2' and the second code gives me NameError: name 'cv2' is not defined.

here is a picture of my opencv requirements enter image description here

i tried pip install opencv-python

enter image description here but all the requirement were met

Upvotes: 1

Views: 1739

Answers (1)

Nic13Gamer
Nic13Gamer

Reputation: 92

Try using pip3 install opencv-python, as it installs opencv for python3, not python2 (if you have it installed). If you only have python3, pip and pip3 are basically the same thing (I think).

Upvotes: 1

Related Questions