In this post, you will learn about Pygame such as how to fix Pygame. error: video system not initialized so let’s go and start.
Running your pygame code will result in the following error: pygame.error: video system not initialized. It is necessary to initialize Pygame before you can do much with it. This is usually done by calling one method.
Pygame allows you to make pretty much the simplest of codes. The program creates a window and allows you to close it. Unfortunately, I am getting the error pygame.error: video system not initialized.
Fix Pygame. error: video system not initialized
According to my search online, most people fail to call pygame.init(). I don’t know why I’m receiving this error. Throughout your game, you haven’t called pygame.init(). This is about the most straightforward program you can write in Pygame. It creates a window and allows you to close it. However, I am getting the following error pygame.error: video system not initialized
It would be best to say that this error occurs when you quit the game. All the pygame modules are uninitialized with pygame. Quit (), but the while loop continues to run, and pygame still runs. The display. update() is called, the video system becomes uninitialized, and errors occur. You can fix this by implementing the following:
pygame.error: video system not initialized
import pygame running = True while running: pygame.init() for event in pygame.event.get(): if event.type == quit: running = False
# When the while loop is complete, uninitialized pygame and exit the program. pygame.quit()
pygame 2.1.0 (SDL 2.0.16, Python 3.6.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
Sys.exit() # import sys at the top of the module.
- Pygame needs to be initialized using this command pygame. If the problem is not resolved, follow these steps:
- Using a beta version causes this problem.
- As a result, I suggest you use the new, old version(if you are using 3.8 Pythons, you need to install Python 3.7)
- Now run pip install pygame in the python terminal (pip install pygame).
- The problem has now been resolved.
NameError: name ‘QUIT’ is not defined
Use this word “quit” instead of “QUIT”
There’s no call to pygame. init() anywhere.
Learn about Import and Initialize in the basic Intro tutorial or the specific Import and Initialize tutorial, which explains that Pygame needs to be initialized before doing much with it. You usually need to make one call to do this. pygame.init()
ModuleNotFoundError: No module named ‘pygame’
- Go to CMD and run this command: pip install pygame.
- If it will work perfectly then no need to again install.
- That’s all.
Most of the time you will face this error while running any Python game with the library of Pygame so, be aware of the bugs. Let’s fix it also.
Read More: Way to fix Python indentation
Pygame error, No video mode has been set
You may be getting this error because you don’t have the right video driver installed, or your graphics card isn’t powerful enough to run pygame. You can try updating your video driver or trying a different graphics card.