【问题标题】:import pandas causing debug mode to terminate导入 pandas 导致调试模式终止
【发布时间】:2019-07-04 19:18:57
【问题描述】:

在我的 macbookpro macOS Mojave 10.14.2 (18C54) 上,我正在使用 PyCharm 调试我的 python 代码 (Python3.6),我在调试模式下收到如下错误消息:

2019-02-11 17:59:46.750 python3.6[1727:27356] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7fa9565936d0
2019-02-11 17:59:46.752 python3.6[1727:27356] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7fa9565936d0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff2ff3aecd __exceptionPreprocess + 256
    1   libobjc.A.dylib                     0x00007fff5bff2720 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff2ffb8275 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x00007fff2fedcb40 ___forwarding___ + 1486
    4   CoreFoundation                      0x00007fff2fedc4e8 _CF_forwarding_prep_0 + 120
    5   libtk8.6.dylib                      0x000000011eb4231d TkpInit + 413
    6   libtk8.6.dylib                      0x000000011ea9a17e Initialize + 2622
    7   _tkinter.cpython-36m-darwin.so      0x000000011e8c2a16 _tkinter_create + 1174
    8   python3.6                           0x000000010839c068 _PyCFunction_FastCallDict + 200
    9   python3.6                           0x000000010847161f call_function + 143
    10  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    11  pydevd_frame_evaluator_darwin_36_64.cpython-36m-darwin.so 0x000000010a984d01 __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 10625
    12  python3.6                           0x00000001084628c9 _PyEval_EvalCodeWithName + 425
    13  python3.6                           0x00000001084722cc _PyFunction_FastCallDict + 364
    14  python3.6                           0x000000010831af80 _PyObject_FastCallDict + 320
    15  python3.6                           0x00000001083425f8 method_call + 136
    16  python3.6                           0x00000001083225ce PyObject_Call + 62
    17  python3.6                           0x00000001083c35b5 slot_tp_init + 117
    18  python3.6                           0x00000001083c7af1 type_call + 241
    19  python3.6                           0x000000010831aef1 _PyObject_FastCallDict + 177
    20  python3.6                           0x0000000108471718 call_function + 392
    21  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    22  pydevd_frame_evaluator_darwin_36_64.cpython-36m-darwin.so 0x000000010a984d01 __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 10625
    23  python3.6                           0x00000001084628c9 _PyEval_EvalCodeWithName + 425
    24  python3.6                           0x0000000108471a8a fast_function + 362
    25  python3.6                           0x000000010847167c call_function + 236
    26  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    27  pydevd_frame_evaluator_darwin_36_64.cpython-36m-darwin.so 0x000000010a984d01 __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 10625
    28  python3.6                           0x00000001084628c9 _PyEval_EvalCodeWithName + 425
    29  python3.6                           0x0000000108471a8a fast_function + 362
    30  python3.6                           0x000000010847167c call_function + 236
    31  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    32  pydevd_frame_evaluator_darwin_36_64.cpython-36m-darwin.so 0x000000010a984d01 __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 10625
    33  python3.6                           0x00000001084719dc fast_function + 188
    34  python3.6                           0x000000010847167c call_function + 236
    35  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    36  pydevd_frame_evaluator_darwin_36_64.cpython-36m-darwin.so 0x000000010a984d01 __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 10625
    37  python3.6                           0x00000001084719dc fast_function + 188
    38  python3.6                           0x000000010847167c call_function + 236
    39  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    40  pydevd_frame_evaluator_darwin_36_64.cpython-36m-darwin.so 0x000000010a984d01 __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 10625
    41  python3.6                           0x00000001084628c9 _PyEval_EvalCodeWithName + 425
    42  python3.6                           0x0000000108471a8a fast_function + 362
    43  python3.6                           0x000000010847167c call_function + 236
    44  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    45  pydevd_frame_evaluator_darwin_36_64.cpython-36m-darwin.so 0x000000010a984d01 __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 10625
    46  python3.6                           0x00000001084719dc fast_function + 188
    47  python3.6                           0x000000010847167c call_function + 236
    48  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    49  pydevd_frame_evaluator_darwin_36_64.cpython-36m-darwin.so 0x000000010a984d01 __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 10625
    50  python3.6                           0x00000001084628c9 _PyEval_EvalCodeWithName + 425
    51  python3.6                           0x0000000108471a8a fast_function + 362
    52  python3.6                           0x000000010847167c call_function + 236
    53  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    54  pydevd_frame_evaluator_darwin_36_64.cpython-36m-darwin.so 0x000000010a98506d __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 11501
    55  python3.6                           0x00000001084719dc fast_function + 188
    56  python3.6                           0x000000010847167c call_function + 236
    57  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    58  pydevd_frame_evaluator_darwin_36_64.cpython-36m-darwin.so 0x000000010a984ad7 __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 10071
    59  python3.6                           0x00000001084628c9 _PyEval_EvalCodeWithName + 425
    60  python3.6                           0x000000010845d129 builtin_exec + 345
    61  python3.6                           0x000000010839c068 _PyCFunction_FastCallDict + 200
    62  python3.6                           0x000000010847161f call_function + 143
    63  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    64  pydevd_frame_evaluator_darwin_36_64.cpython-36m-darwin.so 0x000000010a98506d __pyx_f_18_pydevd_frame_eval_35pydevd_frame_evaluator_darwin_36_64_get_bytecode_while_frame_eval + 11501
    65  python3.6                           0x00000001084628c9 _PyEval_EvalCodeWithName + 425
    66  python3.6                           0x0000000108471a8a fast_function + 362
    67  python3.6                           0x000000010847167c call_function + 236
    68  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    69  python3.6                           0x00000001084628c9 _PyEval_EvalCodeWithName + 425
    70  python3.6                           0x0000000108471a8a fast_function + 362
    71  python3.6                           0x000000010847167c call_function + 236
    72  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    73  python3.6                           0x00000001084719dc fast_function + 188
    74  python3.6                           0x000000010847167c call_function + 236
    75  python3.6                           0x000000010846f175 _PyEval_EvalFrameDefault + 46837
    76  python3.6                           0x00000001084628c9 _PyEval_EvalCodeWithName + 425
    77  python3.6                           0x00000001084bb55c PyRun_FileExFlags + 252
    78  python3.6                           0x00000001084baa34 PyRun_SimpleFileExFlags + 372
    79  python3.6                           0x00000001084e17c6 Py_Main + 3734
    80  python3.6                           0x0000000108312f59 main + 313
    81  libdyld.dylib                       0x00007fff5d0c0ed9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

我试图测试哪个代码行触发了这个问题,并发现“import pandas as pd”导致了这个问题...... 即使使用下面的代码,调试模式也会以异常结束,当我在“a = 1 + 2”行切换断点时:

import pandas as pd

print("hello world")
a = 1 + 2
print(a)

【问题讨论】:

  • 我左右读到 pandas 在其某些文件中指向 matplotlib,这会导致 Mac OS 问题。试试this solution,有用吗?

标签: python pandas


【解决方案1】:

问题是由pandas 正在使用的另一个库matplotlib 引起的。

解决方法是一样的,setting the TkAgg backend explictly。将此添加到您的代码中:

import matplotlib
matplotlib.use("TkAgg")

或者,如果您不想编辑代码,您可以使用matplotlib 正在读取的以下环境变量:

MPLBACKEND=TkAgg

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-26
    • 1970-01-01
    • 2017-11-14
    • 2019-08-06
    相关资源
    最近更新 更多