Jump to content

Visual Studio Code refuses to aknowledge that the opencv module exists in python

AndreiArgeanu

So, I'm learning opencv in python and I ended up switching to my laptop so I can use the webcam for video feed. Issues is, after I installed opencv and numpy I still get the error "ModuleNotFoundError: No module named 'cv2'". If I open python either separately from visual studio code or inside the vsc terminal and write import cv2 I don't get such errors. I have tried uninstalling the module and installing it again, restarting my pc. And tried to install it using pip3 install opencv-python instead of pip. I've also tried just writing from cv2 import cv2 instead of just import cv2 but that didn't make a difference. Not sure what I'm supposed to do.

Here's the code I have so far that I'm trying to run, though not sure if it's relevant.

import cv2
import numpy as np

cap=cv2.VideoCapture(0)

while True:
    ret, frame=cap.read()

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×