pygame.error: No available video device

前端 未结 6 868
南方客
南方客 2020-12-11 04:11

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 scr

相关标签:
6条回答
  • 2020-12-11 04:25

    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.

    0 讨论(0)
  • 2020-12-11 04:36

    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.

    0 讨论(0)
  • 2020-12-11 04:36

    Try the following:

    import pygame
    from pygame.locals import *
    pygame.init()
    
    0 讨论(0)
  • 2020-12-11 04:39

    On Linux you can solve the problem using x11.

    Verify that your SDL was built with x11 support, otherwise build it yourself only after that you added some libraries in this way:

    sudo apt install xorg-dev libx11-dev libgl1-mesa-glx
    

    Maybe xorg-dev already installs libx11-dev

    Build SDL from source and enjoy

    0 讨论(0)
  • 2020-12-11 04:41

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

    import os
    os.environ["SDL_VIDEODRIVER"] = "dummy"
    
    0 讨论(0)
  • 2020-12-11 04:41

    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

    0 讨论(0)
提交回复
热议问题