【发布时间】:2021-04-06 19:37:43
【问题描述】:
我尝试使用 Pycharm 运行这些行,但我总是收到此错误: 导入pygame pygame.init()
screen = pygame.display.set_mode((500, 500)) 我设法很好地导入和初始化 Pygame,但之后我无法运行任何代码。还会弹出一个窗口,提示我的 Python 意外退出。
2020-12-30 17:12:41.797 Python[683:12026] -[CAMetalLayer setDisplaySyncEnabled:]: unrecognized selector sent to instance 0x7fb453e60250
2020-12-30 17:12:41.803 Python[683:12026] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CAMetalLayer setDisplaySyncEnabled:]: unrecognized selector sent to instance 0x7fb453e60250'
*** First throw call stack:
(
0 CoreFoundation 0x00000001040c27eb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff9c58048d objc_exception_throw + 48
2 CoreFoundation 0x0000000104144464 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000104033e65 ___forwarding___ + 1061
4 CoreFoundation 0x00000001040339b8 _CF_forwarding_prep_0 + 120
5 libSDL2-2.0.dylib 0x000000010523e0d7 METAL_CreateRenderer + 2359
6 libSDL2-2.0.dylib 0x000000010518072d SDL_CreateRenderer_REAL + 189
7 libSDL2-2.0.dylib 0x00000001051fb629 SDL_CreateWindowTexture + 457
8 libSDL2-2.0.dylib 0x00000001051ffa27 SDL_GetWindowSurface_REAL + 167
9 display.cpython-37m-darwin.so 0x000000010ed33713 pg_set_mode + 2179
10 Python 0x000000010471494d _PyMethodDef_RawFastCallKeywords + 685
11 Python 0x0000000104713dba _PyCFunction_FastCallKeywords + 42
12 Python 0x00000001047d35ae call_function + 782
13 Python 0x00000001047d0560 _PyEval_EvalFrameDefault + 25152
14 Python 0x00000001047d4096 _PyEval_EvalCodeWithName + 2422
15 Python 0x00000001047ca244 PyEval_EvalCode + 100
16 Python 0x0000000104807041 PyRun_FileExFlags + 209
17 Python 0x00000001048068eb PyRun_SimpleFileExFlags + 859
18 Python 0x000000010482493c pymain_main + 8044
19 Python 0x0000000104824da1 _Py_UnixMain + 129
20 libdyld.dylib 0x0000000104e4d235 start + 1
21 ??? 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
【问题讨论】:
-
是否开启全屏模式?
-
是的,它处于全屏模式
-
Python、pygame 和 OS 版本是什么?你从哪里得到 pygame?
-
Python 3.7.0 和 pygame 2.0.0。我通过 Pycharm 中的 python 解释器安装了 pygame