import cv2 cap = cv2.VideoCapture(0) # Try other indices like 1 or 2 if 0 doesn't work if not cap.isOpened(): print("Error: Could not access the camera.") else: print("Camera is working!") cap.release()