2

I'm getting an import error when I try to import the camera module from pygame in python. I'm using Pycharm.

The error is:

Traceback (most recent call last)
line 6, in <module>
    pygame.camera.init()
AttributeError: 'module' object has no attribute 'camera'

Process finished with exit code 1

The code is -

#!/usr/bin/python
import pygame, sys

from pygame.locals import *

pygame.init()

pygame.camera.init()

screen = pygame.display.set_mode((640,480))

cam = pygame.camera.Camera("/dev/video0",(640,480))

cam.start()

while True:

    image = cam.get_image()

    screen.blit(image,(0,0))

    pygame.display.update()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
Loïc Faure-Lacroix
  • 13,220
  • 6
  • 67
  • 99

0 Answers0