[Tutor] pygame not working

Quantz Jeremy jcquantz1 at gmail.com
Wed Aug 16 12:33:05 EDT 2017


I’m not sure if I should be asking here about this, but on my Mac computer, Pygame keeps crashing on me. I have Python 2.7.13 (I can’t use Python 3 because I’m learning from and online course and he’s using Python 2.7.13. Unless you can give me a list or something for all the differences, I am completely new to Python, and a beginner programer.) Mac OS X 32-bit i386/PPC installer. I got my version of Pygame from Pygame.org <http://pygame.org/>, I downloaded the pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg <http://pygame.org/ftp/pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg>. It’s working until I actually try to draw anything on my screen. For example, I can run the following code and it works just fine.

import pygame

pygame.init()
screen = pygame.display.set_mode((900,700))

finished = False

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

But when I run the following code, the Pygame window opens for a split second, then closes and I get a message from my Mac saying Python (My pygame window, not Python IDLE) quit unexpectedly. I’ve looked to see where it crashes and it’s when it reaches where it’s suppose to draw the rectangle. I can’t even see the rectangle for the split second while it’s open. (which if it crashes at that part, it makes sense.) 

import pygame

pygame.init()
screen = pygame.display.set_mode((900,700))

finished = False

while finished == False:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            finished = True
    
    rectOne = pygame.Rect(0,0,800,450)
    
    color = (0,0,255) #R,G,B
    pygame.draw.rect(screen,color,rectOne)
    pygame.display.flip()

I’ll try and give you as much info about my Mac as I can, as I think it’s the computer itself that’s the problem. But if you can’t help me, I do have a windows 10 laptop that I’ve tried putting Pygame on that we could see if you could help me put Pygame on that. I can’t seem to get the right one. I’d rather it on the Mac. I have tried many tutorials as well and nothing is working. I have a 2010 iMac (Old I know) with a 3.06 GHz Intel Core i3 Processor. Graphics are ATI Radeon HD 4670 256 MB. My OS Is X El Capitan Version 10.11.6. I don’t know what of that info you need, or if you need more, but that’s about it. If you could please help me with my problem, it would be much appreciated. I already tried stack overflow, and that didn’t work. I also think it is the computer because someone on there ran my code and it worked just fine. Thanks.
~Ethan


More information about the Tutor mailing list