close

[Solved] pygame.: video system not initialized

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error pygame.: video system not initialized in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How pygame.: video system not initialized Error Occurs?

Today I get the following error pygame.: video system not initialized in python.

How To Solve pygame.: video system not initialized Error ?

  1. How To Solve pygame.: video system not initialized Error ?

    To Solve pygame.: video system not initialized Error There was pygame.init(). There was screen = pygame.display.set_mode((size)) with the variable size in position to be available in the global namespace.

  2. pygame.: video system not initialized

    To Solve pygame.: video system not initialized Error There was pygame.init(). There was screen = pygame.display.set_mode((size)) with the variable size in position to be available in the global namespace.

Solution 1

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

Solution 2

I had this issue recently, and I discovered a strange and unusual bug in the code that I’d written — only after reading it and re-reading it a dozen times over a 10 minute stretch, trying to launch the file (which looked perfect) a dozen times.

There was pygame.init(). There was screen = pygame.display.set_mode((size)) with the variable size in position to be available in the global namespace.

Turns out it was the main game loop.

# main game loop
while RUNNING == True:
    for tneve in pygame.event.get():
        if tneve.type == QUIT:
            print(tneve)
            RUNNING = False
        loop()
        render()
        CLOCK.tick(FPS)
    cleanup()
# End

What a pain!

P.S. The problem is the one-stop-too-far indentation of everything below RUNNING = False.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read