[Python] Why cant sublime find pygame when i try to import it with my code?

Discussão em 'Python' iniciado por Stack, Maio 2, 2025.

  1. Stack

    Stack Membro Participativo

    Im working from the crash course python book and trying to use pygame for one of the projects and both python pygame and pip are all updated to the latest versions but when i try to run the code i get the error "ImportError: No module named pygame"

    import sys

    import pygame

    def run_game():
    #initialize game and create a screen object
    pygame.init()
    screen = pygame.display.set_mode((1200, 800))
    pygame.display.set_caption("Alien Invasion")


    # Start the mai loop for the game.
    while True:

    # Watch for keyboard and mouse events
    for event in pygame.event.get():
    if event.type == pygame.QUIT:
    sys.exit()


    # Make the most recently drawn screen visible.
    pygame.display.flip()

    run_game()

    Continue reading...

Compartilhe esta Página