简体   繁体   中英

Can't import pygame in sublime text on m1 mac

I'm trying to install pygame to use on my m1 mac. I'm trying to just test import the module: import pygame, but keep getting errors.

I found out pygame is installed for python 3, so i switched the build mode to python 3 in sublime text. I keep getting this error:

  File "/Users/username/Documents/python_projects/games/test/test.py", line 1, in <module>
    import pygame
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pygame/__init__.py", line 81, in <module>
    from pygame.base import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pygame/base.cpython-39-darwin.so, 2): Symbol not found: _SDL_DestroyWindow
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pygame/base.cpython-39-darwin.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pygame/base.cpython-39-darwin.so
[Finished in 0.1s with exit code 1]
[cmd: ['python3', '-u', '/Users/username/Documents/python_projects/games/test/test.py']]
[dir: /Users/username/Documents/python_projects/games/test]
[path: /Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

Any help is greatly appreciated

you need to install SDL

download here

get the " Mac OS X " "SDL2-2.0.16.dmg" runtime

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM