Python3 libc++abi:以未捕获的 NSException 类型异常终止

问题描述

我目前正在尝试构建我使用 python3、Pygame 和 aiohttp 模块创建的用于服务器客户端交互的学校项目。当我在我的 ubuntu 20.x 机器上启动它时它可以工作,但是我最近将我的笔记本电脑换成了 M1 MacBook Air 认为它不会导致任何重大问题,因为知道 python 是跨平台的,但是当我启动我的项目时,我得到了以下错误

pygame 2.0.2.dev1 (SDL 2.0.14,Python 3.9.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
Initialisations...
Résolution :  (1000,700)
Affichage démarré. Lancement du site...
======== Running on http://0.0.0.0:8081 ========
(Press CTRL+C to quit)
2021-06-04 21:46:52.603 Python[2480:172004] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException',reason: 'nextEventMatchingMask should only be called from the Main Thread!'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000187e0cc78 __exceptionPreprocess + 240
    1   libobjc.A.dylib                     0x0000000187b350a8 objc_exception_throw + 60
    2   AppKit                              0x000000018a57a900 +[NSEvent _discardTrackingAndCursorEventsIfNeeded] + 0
    3   libSDL2-2.0.0.dylib                 0x0000000103924aa4 Cocoa_PumpEvents + 128
    4   libSDL2-2.0.0.dylib                 0x00000001038acc50 SDL_PumpEvents_REAL + 40
    5   event.cpython-39-darwin.so          0x0000000103b50f98 pg_event_get + 152
    6   Python                              0x00000001025605a4 cfunction_call + 60
    7   Python                              0x0000000102511590 _PyObject_MakeTpCall + 132
    8   Python                              0x0000000102606cd8 call_function + 268
    9   Python                              0x0000000102604640 _PyEval_EvalFrameDefault + 39844
    10  Python                              0x00000001025121fc _PyFunction_Vectorcall + 180
    11  Python                              0x0000000102606c4c call_function + 128
    12  Python                              0x00000001026045c4 _PyEval_EvalFrameDefault + 39720
    13  Python                              0x00000001025121fc _PyFunction_Vectorcall + 180
    14  Python                              0x0000000102606c4c call_function + 128
    15  Python                              0x00000001026045c4 _PyEval_EvalFrameDefault + 39720
    16  Python                              0x00000001025121fc _PyFunction_Vectorcall + 180
    17  Python                              0x0000000102514da0 method_vectorcall + 388
    18  Python                              0x00000001026be2a4 t_bootstrap + 128
    19  Python                              0x000000010265eeb0 pythread_wrapper + 48
    20  libsystem_pthread.dylib             0x0000000187c8f878 _pthread_start + 320
    21  libsystem_pthread.dylib             0x0000000187c8a5e0 thread_start + 8
)
libc++abi: terminating with uncaught exception of type NSException
./jeu.sh: line 3:  2480 Abort trap: 6           python3 main.py

我尝试在谷歌和这个论坛上搜索解决方案,但没有任何效果/这是一个类似的错误,但原因不同。如果有人可以帮助我,将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)