PyCharm 中的断点

Broken breakpoints in PyCharm

每当我 运行 我的 Pycharm 项目处于调试模式时,我的断点就会触发,但只会触发一秒钟。然后执行自动继续。我在控制台中得到一条长长的红色堆栈跟踪。我会在下面 post 我的踪迹,但我的号码是:

2021-10-23 18:02:58.303 python3.6[32922:2949604] -[NSApplication macMinorVersion]: 无法识别的选择器发送到实例 0x7ff5647d1620 2021-10-23 18:02:58.314 python3.6[32922:2949604] *** 由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,原因:'-[NSApplication macMinorVersion]:无法识别的选择器发送到实例 0x7ff5647d1620' *** 首先抛出调用栈: ( 0 核心基础 0x00007fff2067f1db __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007fff203b8d92 objc_exception_throw + 48 2 CoreFoundation 0x00007fff20701d0d -[NSObject(NSObject) __retain_OA] + 0 3 CoreFoundation 0x00007fff205e724b 转发 + 1448 4 核心基础 0x00007fff205e6c18 _CF_forwarding_prep_0 + 120 5 libtk8.6.dylib 0x000000011c2a4db9 SetCGColorComponents + 265 6 libtk8。6.dylib 0x000000011c2a567a TkpGetColor + 250 7 libtk8.6.dylib 0x000000011c1dfaa9 Tk_GetColor + 153 8 libtk8.6.dylib 0x000000011c1cf8e6 Tk_Get3DBorder + 134 9 libtk8.6.dylib 0x000000011c1cf74f Tk_Alloc3DBorderFromObj + 127 10 libtk8.6.dylib 0x000000011c1e0fad DoObjConfig + 941 11 libtk8.6.dylib 0x000000011c1e0ae5 Tk_InitOptions + 357 12 libtk8.6.dylib 0x000000011c1e09c5 Tk_InitOptions + 69 13 libtk8.6.dylib 0x000000011c211b5c CreateFrame + 1548 14 libtk8.6.dylib 0x000000011c211e37 TkListCreateFrame + 151 15 libtk8.6.dylib 0x000000011c2097f8 初始化 + 2168 16 _tkinter.cpython-36m-darwin.so 0x0000000117628adc Tkapp_New + 892 17 _tkinter.cpython-36m-darwin.so 0x0000000117628601 _tkinter_create + 289 18 python3.6 0x0000000108fb4d56 _PyCFunction_FastCallDict + 342 19 python3.6 0x000000010908061a call_function + 154 20 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 21 pydevd_frame_evaluator_darwin_36_64 0x0000000109d0442f __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 2431 22 python3.6 0x0000000109071dc5 _PyEval_EvalCodeWithName + 533 23 python3.6 0x0000000109081394 _PyFunction_FastCallDict + 420 24 python3.6 0x0000000108f389e0 _PyObject_FastCallDict + 336 25 python3.6 0x0000000108f5e11a method_call + 122 26 python3.6 0x0000000108f3eede PyObject_Call + 62 27 python3.6 0x0000000108fdba45 slot_tp_init + 117 28 python3.6 0x0000000108fe0e0b type_call + 235 29 python3.6 0x0000000108f38952 _PyObject_FastCallDict + 194 30 python3.6 0x0000000109080734 call_function + 436 31 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 32 pydevd_frame_evaluator_darwin_36_64 0x0000000109d0442f __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 2431 33 python3.6 0x0000000109071dc5 _PyEval_EvalCodeWithName + 533 34 python3.6 0x0000000109080b06 fast_function + 374 35 python3.6 0x00000001090806d2 call_function + 338 36 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 37 pydevd_frame_evaluator_darwin_36_64 0x0000000109d0442f __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 2431 38 python3.6 0x0000000109071dc5 _PyEval_EvalCodeWithName + 533 39 python3.6 0x0000000109080b06 fast_function + 374 40 python3.6 0x00000001090806d2 call_function + 338 41 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 42 pydevd_frame_evaluator_darwin_36_64 0x0000000109d0442f __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 2431 43 python3.6 0x0000000109080a6e fast_function + 222 44 python3.6 0x00000001090806d2 call_function + 338 45 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 46 pydevd_frame_evaluator_darwin_36_64 0x0000000109d0442f __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 2431 47 python3.6 0x0000000109080a6e fast_function + 222 48 python3.6 0x00000001090806d2 call_function + 338 49 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 50 pydevd_frame_evaluator_darwin_36_64 0x0000000109d0442f __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 2431 51 python3.6 0x0000000109071dc5 _PyEval_EvalCodeWithName + 533 52 python3.6 0x0000000109080b06 fast_function + 374 53 python3.6 0x00000001090806d2 call_function + 338 54 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 55 pydevd_frame_evaluator_darwin_36_64 0x0000000109d0442f __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 2431 56 python3.6 0x0000000109080a6e fast_function + 222 57 python3.6 0x00000001090806d2 call_function + 338 58 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 59 pydevd_frame_evaluator_darwin_36_64 0x0000000109d0442f __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 2431 60 python3.6 0x0000000109080a6e fast_function + 222 61 python3.6 0x00000001090806d2 call_function + 338 62 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 63 pydevd_frame_evaluator_darwin_36_64 0x0000000109d0442f __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 2431 64 python3.6 0x0000000109071dc5 _PyEval_EvalCodeWithName + 533 65 python3.6 0x0000000109081394 _PyFunction_FastCallDict + 420 66 python3.6 0x0000000108f389e0 _PyObject_FastCallDict + 336 67 python3.6 0x0000000108f5e11a method_call + 122 68 pydevd_cython_darwin_36_64.cpython- 0x0000000109c27411 __Pyx_PyObject_Call + 97 69 pydevd_cython_darwin_36_64.cpython- 0x0000000109c4b7b5 __pyx_pw_14_pydevd_bundle_26pydevd_cython_darwin_36_64_9PyDBFrame_5do_wait_suspend + 165 70 python3.6 0x0000000108fb475e PyCFunction_Call + 142 71 pydevd_cython_darwin_36_64.cpython- 0x0000000109c27411 __Pyx_PyObject_Call + 97 72 pydevd_cython_darwin_36_64.cpython- 0x0000000109c311cf __pyx_f_14_pydevd_bundle_26pydevd_cython_darwin_36_64_9PyDBFrame_trace_dispatch + 33135 73 pydevd_cython_darwin_36_64.cpython- 0x0000000109c728e7 pyx_pf_14_pydevd_bundle_26pydevd_cython_darwin_36_64_12ThreadTracer_2__call + 18791 74 python3.6 0x0000000108f38952 _PyObject_FastCallDict + 194 75 python3.6 0x00000001090e5f55 trace_trampoline + 133 76 python3.6 0x000000010907a8ff _PyEval_EvalFrameDefault + 29919 77 pydevd_frame_evaluator_darwin_36_64 0x0000000109d052ec __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 6204 78 python3.6 0x0000000109071dc5 _PyEval_EvalCodeWithName + 533 79 python3.6 0x000000010906cd35 builtin_exec + 341 80 python3.6 0x0000000108fb4d56 _PyCFunction_FastCallDict + 342 81 python3.6 0x000000010908061a call_function + 154 82 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 83 pydevd_frame_evaluator_darwin_36_64 0x0000000109d052ec __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 6204 84 python3.6 0x0000000109071dc5 _PyEval_EvalCodeWithName + 533 85 python3.6 0x0000000109080b06 fast_function + 374 86 python3.6 0x00000001090806d2 call_function + 338 87 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 88 pydevd_frame_evaluator_darwin_36_64 0x0000000109d052ec __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 6204 89 python3.6 0x0000000109080a6e fast_function + 222 90 python3.6 0x00000001090806d2 call_function + 338 91 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 92 python3.6 0x0000000109071dc5 _PyEval_EvalCodeWithName + 533 93 python3.6 0x0000000109080b06 fast_function + 374 94 python3.6 0x00000001090806d2 call_function + 338 95 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 96 python3.6 0x0000000109080a6e fast_function + 222 97 python3.6 0x00000001090806d2 call_function + 338 98 python3.6 0x0000000109078c3e _PyEval_EvalFrameDefault + 22558 99 python3.6 0x0000000109071dc5 _PyEval_EvalCodeWithName + 533 100 python3.6 0x00000001090d52db PyRun_FileExFlags + 235 101 python3.6 0x00000001090d4ca8 PyRun_SimpleFileExFlags + 504 102 python3.6 0x00000001090fa2ca run_file + 170 103 python3.6 0x00000001090f9492 Py_Main + 2930 104 python3.6 0x0000000108f31a04 主 + 276 105 libdyld.dylib 0x00007fff20528f3d 开始 + 1 ) libc++abi:以 NSException

类型的未捕获异常终止

看起来是由于 matplotlib 缺少 Mac 支持造成的。

使用:

import matplotlib
matplotlib.use("TkAgg")
from matplotlib import pyplot as pet

按照“krisdigital”的建议 here 似乎解决了我的问题。