May-05-2019, 10:15 AM
pip install pygameworks but when I try to run some basic code that uses the pygame module I get this error
ModuleNotFoundError: No Module Named 'pygame' on line 2
I am using Spyder (Python 3.6) on Ubuntu 18.04
Here is the code I'm trying to run
# Pygame template - skeleton for a new pygame project import pygame import random WIDTH = 360 HEIGHT = 480 FPS = 30 # define colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) # initialize pygame and create window pygame.init() pygame.mixer.init() screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("My Game") clock = pygame.time.Clock() # Game loop running = True while running: # keep loop running at the right speed clock.tick(FPS) # Process input (events) for event in pygame.event.get(): # check for closing window if event.type == pygame.QUIT: running = False # Update # Draw / render screen.fill(BLACK) # *after* drawing everything, flip the display pygame.display.flip() pygame.quit()