How do I fix pygame.error: video system not initialized in replit


I’m playing around with Pygame, and when I clicked Run for the first time, Pygame gives me the error

pygame.error: video system not initialized

How do I fix this?

The code I have at the moment is

import pygame


white = (255, 255, 255)
green = (0, 255, 0)
blue = (0, 0, 128)
X = 400
Y = 400
display_surface = pygame.display.set_mode((X, Y))
pygame.display.set_caption('Epic SAVER')
font = pygame.font.Font('freesansbold.ttf', 32)
text = font.render('Epic SAVER', True, green, blue)
textRect = text.get_rect() = (X // 2, Y // 2)

while True:
    display_surface.blit(text, textRect)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:

I’m running this in Replit, and how would I fix this?
I got this off of the internet because I don’t know Pygame that well

>Solution : allows creating Python/PyGame scripts and multiplayer coding. When creating a new repl, select the Pygame template:

Leave a Reply Cancel reply