1

This is the code

import pygame
background_colour = (255,255,255)
(width, height) = (300, 200)
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('Tutorial 1')
screen.fill(background_colour)
pygame.display.flip()
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

When I run this code on Pycharm or on idle, I get a bouncing python rocket icon on the dock (this is on MacOS), however when I run the code line by line in the terminal, the code successfully creates a pygame window. The same code works on Pycharm on windows.

martineau
  • 119,623
  • 25
  • 170
  • 301

1 Answers1

0

Very likely you have installed different versions of Python on your system (also see Two different Python3 and Two different Python2 installations on MacOS Catalina). Certainly Pycharm has its own Python version and the terminal uses a different Python installation. Therefor you can't run the code from the terminal. One way to solve the problem is to install Pygame via the terminal:

pip3 install pygame
Rabbid76
  • 202,892
  • 27
  • 131
  • 174