0

I have pygame and numpy installed and both seem to be working on win10 from python shell:

import pygame

(working)

put in a script:

import pygame, sys
from pygame.locals import * 
pygame.init() 
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Hello World!')  
while True: # main game loop  
    for event in pygame.event.get():
        if event.type == QUIT: 
            pygame.quit() 
            sys.exit()
    pygame.display.update()

Pygame window opens and python stops. Before I exit out of python says in the python shell "no module named pygame"

1
  • Did you check which version of python your shell is using, compared to which python is your system default? Commented Aug 25, 2021 at 17:07

1 Answer 1

1

Try to install with pip. From the command line type:

pip install pygame
Sign up to request clarification or add additional context in comments.

1 Comment

Check that pip is installing to the Python3 environment and not Python2. pip3 would be a better choice

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.