Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pygame.error: No available video device

Tags:

python

pygame

I have this setup:

 $ python -V
Python 2.7.2+
 $ python -c "import pygame; print pygame.__version__"
1.9.1release

When I run a pygame script, I get this error:

Traceback (most recent call last):
  File "/home/santosh/tmp/pygameHelloWorld.py", line 8, in <module>
    windowSurface = pygame.display.set_mode((500, 400), 0, 32)
pygame.error: No available video device

I am using Ubuntu and have install pygame with apt-get. Additionally I have install all dependencies mentioned on this pygame wiki page.

like image 950
Santosh Kumar Avatar asked Apr 10 '13 18:04

Santosh Kumar


People also ask

Can we add video in pygame?

pygamevideo module helps developer to embed videos into their Pygame display.

Why is pygame init () not working?

The pygame. init() error is caused by its function not being called and can be solved with the import and initialization of pygame modules.


2 Answers

If you are running Pygame on a UNIX system, like a Linux server, try using a DummyVideoDriver:

import os
os.environ["SDL_VIDEODRIVER"] = "dummy"
like image 166
fushan Avatar answered Nov 10 '22 10:11

fushan


From similar experience the most likely problem is something is wrong with one of your SDL packages. Try running the following.

import pygame
pygame.init()
pygame.display.list_modes()

If you get back an empty list, it's definitely because of the packages. Try reinstalling them.

Possibly related:

  • SDL init failure, reason is: No available video device

  • SDL init failure, reason is: No available video device in ubuntu 12.04 LTS

like image 37
iKlsR Avatar answered Nov 10 '22 11:11

iKlsR