Python crash and exit when using plt.show()

System: OS X 10.10.3
Python: 2.7.6
matplotlib: 1.4.3

error log:

2015-07-06 15:26:13.383 Python[10852:950226] An uncaught exception was raised
2015-07-06 15:26:13.383 Python[10852:950226] Error (1000) creating CGSWindow on line 281
2015-07-06 15:26:13.383 Python[10852:950226] (
    0   CoreFoundation                      0x00007fff832a703c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8cdc876e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff832a6eed +[NSException raise:format:] + 205
    3   AppKit                              0x00007fff8f816dd2 _NSCreateWindowWithOpaqueShape2 + 1417
    4   AppKit                              0x00007fff8f815058 -[NSWindow _commonAwake] + 1877
    5   AppKit                              0x00007fff8f89fb29 -[NSWindow _makeKeyRegardlessOfVisibility] + 85
    6   AppKit                              0x00007fff8f89fa9e -[NSWindow makeKeyAndOrderFront:] + 27
    7   _macosx.so                          0x000000010f1123ea FigureManager_show + 74
    8   Python                              0x000000010d9b89ed PyEval_EvalFrameEx + 14935
    9   Python                              0x000000010d9b4d62 PyEval_EvalCodeEx + 1413
    10  Python                              0x000000010d95930a PyFunction_SetClosure + 826
    11  Python                              0x000000010d93b2ac PyObject_Call + 99
    12  Python                              0x000000010d9460cf PyMethod_New + 1210
    13  Python                              0x000000010d93b2ac PyObject_Call + 99
    14  Python                              0x000000010d9819af _PyObject_SlotCompare + 2963
    15  Python                              0x000000010d93b2ac PyObject_Call + 99
    16  Python                              0x000000010d9b79ba PyEval_EvalFrameEx + 10788
    17  Python                              0x000000010d9b4d62 PyEval_EvalCodeEx + 1413
    18  Python                              0x000000010d9bb57d _PyEval_SliceIndex + 757
    19  Python                              0x000000010d9b83e3 PyEval_EvalFrameEx + 13389
    20  Python                              0x000000010d9b4d62 PyEval_EvalCodeEx + 1413
    21  Python                              0x000000010d9b47d7 PyEval_EvalCode + 54
    22  Python                              0x000000010d9d47bd PyParser_ASTFromFile + 315
    23  Python                              0x000000010d9d4860 PyRun_FileExFlags + 133
    24  Python                              0x000000010d9d43fd PyRun_SimpleFileExFlags + 769
    25  Python                              0x000000010d9e5b23 Py_Main + 3051
    26  libdyld.dylib                       0x00007fff8e9925c9 start + 1
    27  ???                                 0x0000000000000002 0x0 + 2
)
2015-07-06 15:26:13.384 Python[10852:950226] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1000) creating CGSWindow on line 281'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff832a703c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8cdc876e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff832a6eed +[NSException raise:format:] + 205
    3   AppKit                              0x00007fff8f816dd2 _NSCreateWindowWithOpaqueShape2 + 1417
    4   AppKit                              0x00007fff8f815058 -[NSWindow _commonAwake] + 1877
    5   AppKit                              0x00007fff8f89fb29 -[NSWindow _makeKeyRegardlessOfVisibility] + 85
    6   AppKit                              0x00007fff8f89fa9e -[NSWindow makeKeyAndOrderFront:] + 27
    7   _macosx.so                          0x000000010f1123ea FigureManager_show + 74
    8   Python                              0x000000010d9b89ed PyEval_EvalFrameEx + 14935
    9   Python                              0x000000010d9b4d62 PyEval_EvalCodeEx + 1413
    10  Python                              0x000000010d95930a PyFunction_SetClosure + 826
    11  Python                              0x000000010d93b2ac PyObject_Call + 99
    12  Python                              0x000000010d9460cf PyMethod_New + 1210
    13  Python                              0x000000010d93b2ac PyObject_Call + 99
    14  Python                              0x000000010d9819af _PyObject_SlotCompare + 2963
    15  Python                              0x000000010d93b2ac PyObject_Call + 99
    16  Python                              0x000000010d9b79ba PyEval_EvalFrameEx + 10788
    17  Python                              0x000000010d9b4d62 PyEval_EvalCodeEx + 1413
    18  Python                              0x000000010d9bb57d _PyEval_SliceIndex + 757
    19  Python                              0x000000010d9b83e3 PyEval_EvalFrameEx + 13389
    20  Python                              0x000000010d9b4d62 PyEval_EvalCodeEx + 1413
    21  Python                              0x000000010d9b47d7 PyEval_EvalCode + 54
    22  Python                              0x000000010d9d47bd PyParser_ASTFromFile + 315
    23  Python                              0x000000010d9d4860 PyRun_FileExFlags + 133
    24  Python                              0x000000010d9d43fd PyRun_SimpleFileExFlags + 769
    25  Python                              0x000000010d9e5b23 Py_Main + 3051
    26  libdyld.dylib                       0x00007fff8e9925c9 start + 1
    27  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Author: Fantashit

2 thoughts on “Python crash and exit when using plt.show()

  1. For everyone that still has this issue, this helped me:

    import matplotlib
    matplotlib.use("TkAgg")
    import matplotlib.pyplot as plt
    

    From here

    BTW: I’m not using any GUI so this sound to me like a matplotlib bug(?)

    For me it crashes on this line:

    fig = plt.figure()
    

Comments are closed.