mac python3 conda pytorch出错:libc++abi.dylib: terminating with uncaught exception of type NSException

时间:2024-01-16 14:00:33

mac 10.14/ conda/python 3.7环境下运行神经网络例子出现错误:

-- ::55.982 python[:] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7fd5a5811270
-- ::55.988 python[:] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7fd5a5811270'
*** First throw call stack:
(
CoreFoundation 0x00007fff3c94643d __exceptionPreprocess +
libobjc.A.dylib 0x00007fff68853720 objc_exception_throw +
CoreFoundation 0x00007fff3c9c3255 -[NSObject(NSObject) __retain_OA] +
CoreFoundation 0x00007fff3c8e5ad0 ___forwarding___ +
CoreFoundation 0x00007fff3c8e5478 _CF_forwarding_prep_0 +
libtk8..dylib 0x00000001334ee31d TkpInit +
libtk8..dylib 0x000000013344617e Initialize +
_tkinter.cpython-37m-darwin.so 0x000000010727aa0f _tkinter_create +
python 0x0000000105b028b6 _PyMethodDef_RawFastCallKeywords +
python 0x0000000105c3fba2 call_function +
python 0x0000000105c3d852 _PyEval_EvalFrameDefault +
python 0x0000000105c311fe _PyEval_EvalCodeWithName +
python 0x0000000105b01587 _PyFunction_FastCallDict +
python 0x0000000105b83c31 slot_tp_init +
python 0x0000000105b8dc01 type_call +
python 0x0000000105b02283 _PyObject_FastCallKeywords +
python 0x0000000105c3fc35 call_function +
python 0x0000000105c3d946 _PyEval_EvalFrameDefault +
python 0x0000000105b02075 function_code_fastcall +
python 0x0000000105c3fb27 call_function +
python 0x0000000105c3d852 _PyEval_EvalFrameDefault +
python 0x0000000105c311fe _PyEval_EvalCodeWithName +
python 0x0000000105b01587 _PyFunction_FastCallDict +
python 0x0000000105b054a2 method_call +
python 0x0000000105b02ef2 PyObject_Call +
python 0x0000000105c3da9d _PyEval_EvalFrameDefault +
python 0x0000000105c311fe _PyEval_EvalCodeWithName +
python 0x0000000105b02783 _PyFunction_FastCallKeywords +
python 0x0000000105c3fb27 call_function +
python 0x0000000105c3d88d _PyEval_EvalFrameDefault +
python 0x0000000105b02075 function_code_fastcall +
python 0x0000000105c3fb27 call_function +
python 0x0000000105c3d88d _PyEval_EvalFrameDefault +
python 0x0000000105c311fe _PyEval_EvalCodeWithName +
python 0x0000000105b02783 _PyFunction_FastCallKeywords +
python 0x0000000105c3fb27 call_function +
python 0x0000000105c3d88d _PyEval_EvalFrameDefault +
python 0x0000000105c311fe _PyEval_EvalCodeWithName +
python 0x0000000105b02783 _PyFunction_FastCallKeywords +
python 0x0000000105c3fb27 call_function +
python 0x0000000105c3d852 _PyEval_EvalFrameDefault +
python 0x0000000105b02075 function_code_fastcall +
python 0x0000000105c3fb27 call_function +
python 0x0000000105c3d88d _PyEval_EvalFrameDefault +
python 0x0000000105c311fe _PyEval_EvalCodeWithName +
python 0x0000000105c94760 PyRun_FileExFlags +
python 0x0000000105c93bd7 PyRun_SimpleFileExFlags +
python 0x0000000105cc17bf pymain_main +
python 0x0000000105ad4bbd main +
libdyld.dylib 0x00007fff69921085 start +
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap:

解决办法,运行下面的命令:

$ mkdir -p ~/.matplotlib
$ echo "backend: TkAgg" > ~/.matplotlib/matplotlibrc

然后就成功了

具体原因可见:https://github.com/PAHdb/AmesPAHdbPythonSuite/issues/1