pygame.error: video system not initialized

You haven’t called pygame.init() anywhere.

See the basic Intro tutorial, or the specific Import and Initialize tutorial, which explains:

Before you can do much with pygame, you will need to initialize it. The most common way to do this is just make one call.

pygame.init()

This will attempt to initialize all the pygame modules for you. Not all pygame modules need to be initialized, but this will automatically initialize the ones that do. You can also easily initialize each pygame module by hand. For example to only initialize the font module you would just call.

In your particular case, it’s probably pygame.display that’s complaining that you called either its set_caption or its flip without calling its init first. But really, as the tutorial says, it’s better to just init everything at the top than to try to figure out exactly what needs to be initialized when.

Leave a Comment