0

Here's my code:

import pygame, sys
from pygame.locals import *

pygame.init()
#set up window
DISPLAYSURF = pygame.display.set_mode((500, 400), 0, 32) 


#set up the colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255,0,0)
GREEN = (0,255,0)
BLUE = (0,0,255)

#draw on the surface object
DISPLAYSURF.fill(WHITE)
pygame.draw.polygon(DISPLAYSURF, GREEN, ((146, 0), (291,106), (236, 277), (56, 277), (0,106)))
pygame.draw.line(DISPLAYURF, BLUE, (60,60), (120,60), 4)
pygame.draw.line(DISPLAYSURF, BLUE, (120,60), (60,120))
pygame.draw.line(DISPLAYSURF, BLUE, (60, 120), (120,120), 4)
pygame.draw.circle(DISPLAYSURF, BLUE, (300,50), 20, 0)
pygame.draw.ellipse(DISPLAYSURF, RED, (300, 250, 40, 80), 1)
pygame.draw.rect(DISPLAYSURF, RED, (200,150,100,50))

pixObj = pygame.PixelArray(DISPLAYSURF)
pixObj[480][380]= BLACK
pixObj[482][382]= BLACK
pixObj[484][384]= BLACK
pixObj[486][386]= BLACK
pixObj[488][388]= BLACK
del pixObj

while True:
  for event in pygame.event.get():
    if event.type == QUIT:
      pygame.quit()
      sys.exit()
  pygame.display.update()

I'm really not sure what the error means, I tried googling it and literally no one else is getting this error message. It's literally the same exact code from what I was trying to do on a PDF, but it's not working. I just started pygame. Here's the error message:

Traceback (most recent call last):
  File "main.py", line 6, in <module>
    DISPLAYSURF = pygame.display.set_mode((500, 400), 0, 32)
pygame.error: No available video device
Emily
  • 1,030
  • 1
  • 12
  • 20
indentation
  • 77
  • 2
  • 9
  • What happens if you leave the `, 0, 32` out of the `set_mode` ? Is you display capable of running at this colour-depth? – Kingsley Dec 10 '19 at 21:39

1 Answers1

1

Try searching the pygame repository for information and examples on the particular errors. It appears to indicate that the system must be defined.

The code below came from
https://github.com/search?q=pygame.error+No+available+video+device&type=Code

## If you get the no available video device error, copy and paste the below code ##
import platform
if platform.system() == "Windows":
### If you get the no available video device error, copy and paste the above code ###

Also, an SO post with a few answers:
pygame.error: No available video device


**Update: the below link appears to have a working pygame in repl.it

https://repl.it/@amasad/simple-platformer

befunkt
  • 131
  • 8