-1

I'm a very beginner python programmer. I installed pygame however when I import pygame in spyder, it doesn't work. pip install pygame

The following message prompts. ModuleNotFoundError: No module named 'pygame'

Below is what I wrote so far

import pygame

WIDTH, HEIGHT = 900, 500 WIN = pygame.display.set_mode((WITH, HEIGHT))

def main():

run = True

while run:
    
    for event in pygame.event.get():
        #end this while loop
        if event.type == pygame.QUIT:
            run = False
pygame.quit()

2 Answers2

0

Try

py -m pip install pygame
or

python3 -m pip install pygame

dinesh balan
  • 318
  • 1
  • 14
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 13 '21 at 06:54
0

Maybe you’re a user on your computer without elevated privileges which belong to the admin. If the prompt showed an error while installing pygame, it means you do not have the required permissions.
Try to install pygame with the pip install --user pygame

NameError
  • 206
  • 1
  • 3
  • 19