macospython-2.7pygame

Problems getting pygame to show anything but a blank screen on Macos


I recently bought a new macbook and I've been trying endlessly to get pygame to work, but haven't succeeded yet. I'm getting pretty desperate and I could really use some help.

I've installed pygame 1.9.4 and even though I don't get any error messages when running pygame code, it won't show me anything but a blank screen. I'm using the following code to test it:

import pygame
pygame.init()

screen = pygame.display.set_mode((800,600))

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            quit()

    screen.fill((255,0,0))
    pygame.display.update()

pygame.quit()

On my old macbook the test code gives me a red screen as expected. Both macbooks are running python 2.7.10.

Does anyone have any idea what I'm doing wrong? I think I installed pygame exactly like I did on my old macbook and the only difference seems to be the operating system.

edit 1: I write the script in Sublime Text and run the program in Terminal. Screenshot

edit 2: I got pygame working again by downgrading my operating system to macOS High Sierra.


Solution

  • I tried upgrading my old macbook to OS Mojave to see if pygame would stop working, and it did!

    I guess Mojave isn't compatible with pygame (yet).

    Thanks for the help!