pygame.error: No available video device

匿名 (未验证) 提交于 2019-12-03 08:57:35

问题:

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.

回答1:

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. Or you can try compiling a SDL program to see if SDL works. (link with SDLmain and SDL)

Possibly related:



回答2:

This should work but comment if it doesn't. It might only affect Windows XP.

import os os.environ['SDL_VIDEODRIVER']='windlib' 

Good luck. Hope this works.



回答3:

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

import os os.environ["SDL_VIDEODRIVER"] = "dummy" 


回答4:

Wild guess - is the DISPLAY environment variable set and/or required by the library, and not available? This could be the case if you're ssh-ing into the Linux machine you're running this on without providing the -X option.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!