1

I'm really struggling to get even basic code to run in Pycharm with Pygame. It's coming up with a load of errors and I've searched and searched and nothing has worked so far. I'm on a mac laptop. Below is the code I'm trying to run:

import pygame
pygame.init()

screen = pygame.display.set_mode([500, 500])

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

screen.fill((255, 255, 255))

pygame.draw.circle(screen, (0, 0, 255), (250, 250), 75)

pygame.display.flip()

pygame.quit() 

And here is the error response I am getting:

[CAMetalLayer setDisplaySyncEnabled:]: unrecognized selector sent to instance 0x7fa6d971e5f0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CAMetalLayer setDisplaySyncEnabled:]: unrecognized selector sent to instance 0x7fa6d971e5f0'
*** First throw call stack:
(

    0   CoreFoundation                      0x00007fffba6717eb __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fffcf4b248d objc_exception_throw + 48
    2   CoreFoundation                      0x00007fffba6f3464 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x00007fffba5e2e65 ___forwarding___ + 1061
    4   CoreFoundation                      0x00007fffba5e29b8 _CF_forwarding_prep_0 + 120
    5   libSDL2-2.0.dylib                   0x0000000102c93ad1 METAL_CreateRenderer + 2353
    6   libSDL2-2.0.dylib                   0x0000000102bd306d SDL_CreateRenderer_REAL + 189
    7   libSDL2-2.0.dylib                   0x0000000102c4efd9 SDL_CreateWindowTexture + 457
    8   libSDL2-2.0.dylib                   0x0000000102c5369a SDL_GetWindowSurface_REAL + 170
    9   display.cpython-39-darwin.so        0x0000000102ef2723 pg_set_mode + 2147
    10  Python                              0x0000000102589f3b cfunction_call + 59
    11  Python                              0x000000010254b26d _PyObject_MakeTpCall + 365
    12  Python                              0x000000010262199c call_function + 876
    13  Python                              0x000000010261ee33 _PyEval_EvalFrameDefault + 25219
    14  Python                              0x0000000102622603 _PyEval_EvalCode + 2611
    15  Python                              0x0000000102618a8b PyEval_EvalCode + 139
    16  Python                              0x000000010266b382 PyRun_FileExFlags + 434
    17  Python                              0x000000010266a95f PyRun_SimpleFileExFlags + 831
    18  Python                              0x0000000102687829 Py_RunMain + 1801
    19  Python                              0x0000000102687cbf pymain_main + 223
    20  Python                              0x0000000102687ebb Py_BytesMain + 43
    21  libdyld.dylib                       0x00007fffcfdec235 start + 1
    22  ???                                 0x0000000000000002 0x0 + 2
libc++abi.dylib: terminating with uncaught exception of type NSException

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

I am running the latest Pygame, python and pip.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • Looks like a bug in the Mac-specific portion of the Pygame library? The code (mostly) runs fine on Windows. – Carcigenicate Jan 07 '21 at 20:18
  • I have installed pygame on my windows pc instead and it is working, thank you so much. Such a shame that it does not work on mac. – Olivia Berry Jan 07 '21 at 20:40
  • Welcome SO Olivia! Have you checked out https://stackoverflow.com/questions/28003827/python-and-pygame-error-code-134-cannot-figure-out-why ? – demokritos Jan 07 '21 at 20:41
  • The MacOS API they're using may have changed slightly, and Pygame has yet to update to reflect it? Potentially? It may be worth submitting an issue to the Github repo of the library. Also, try a reinstall just in case something went wonky with the original installation. – Carcigenicate Jan 07 '21 at 20:42
  • It seems like it's attempting to make a method call `setDisplaySyncEnabled`, but from some searching, it looks like that's supposed to be [displaySyncEnabled](https://developer.apple.com/documentation/quartzcore/cametallayer/2887087-displaysyncenabled). And actually, there is a [github issue raised](https://github.com/pygame/pygame/issues/1970) for this exact problem already. It looks like you MacOS might be outdated? – Carcigenicate Jan 07 '21 at 20:47
  • pip install pygame==2.0.2 – Evalds Urtans Jul 18 '22 at 13:08

0 Answers0