title: tkinter crashes on ipython, but not in python (on a M1 Mac)
body: <p>I am using a miniconda installation on an M1 Mac and <code>tkinter crashes when I call it from </code>ipython<code>, but not from </code>python`. Here's example code that leads to the crash:</p>
  <pre><code>from tkinter import messagebox
  messagebox.showerror('a','b')
  </code></pre>
  <p>Running this from the python interpreter (at <code>~/miniforge3/bin/</code>) works, but from ipython (same path) causes a crash back to terminal:</p>
  <pre><code>2022-04-21 14:19:39.873 python[56056:2463981] -[NSApplication macOSVersion]: unrecognized selector sent to instance 0x11d627510
  2022-04-21 14:19:39.876 python[56056:2463981] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication macOSVersion]: unrecognized selector sent to instance 0x11d627510'
  *** First throw call stack:
  (
      0   CoreFoundation                      0x0000000192b76b08 __exceptionPreprocess + 240
      1   libobjc.A.dylib                     0x00000001928c1e14 objc_exception_throw + 60
      2   CoreFoundation                      0x0000000192c0aa68 -[NSObject(NSObject) __retain_OA] + 0
      3   CoreFoundation                      0x0000000192ad5e14 ___forwarding___ + 1764
      4   CoreFoundation                      0x0000000192ad5670 _CF_forwarding_prep_0 + 96
      5   libtk8.6.dylib                      0x000000012c3ef918 GetRGBA + 264
      6   libtk8.6.dylib                      0x000000012c3ef728 TkpGetColor + 648
      7   libtk8.6.dylib                      0x000000012c33a1cc Tk_GetColor + 168
      8   libtk8.6.dylib                      0x000000012c32b4e0 Tk_Get3DBorder + 152
      9   libtk8.6.dylib                      0x000000012c32b320 Tk_Alloc3DBorderFromObj + 144
      10  libtk8.6.dylib                      0x000000012c33b77c DoObjConfig + 848
      11  libtk8.6.dylib                      0x000000012c33b334 Tk_InitOptions + 372
      12  libtk8.6.dylib                      0x000000012c33b218 Tk_InitOptions + 88
      13  libtk8.6.dylib                      0x000000012c3683e0 CreateFrame + 1480
      14  libtk8.6.dylib                      0x000000012c36870c TkListCreateFrame + 172
      15  libtk8.6.dylib                      0x000000012c360f68 Initialize + 1856
      16  _tkinter.cpython-39-darwin.so       0x000000012af6e078 Tkapp_New + 876
      17  _tkinter.cpython-39-darwin.so       0x000000012af6d9a0 _tkinter_create + 596
      18  python3.9                           0x00000001025f827c cfunction_vectorcall_FASTCALL + 208
      19  python3.9                           0x00000001026b3614 call_function + 572
      20  python3.9                           0x00000001026afd44 _PyEval_EvalFrameDefault + 29268
      21  python3.9                           0x00000001026a84a8 _PyEval_EvalCode + 2968
      22  python3.9                           0x00000001025a3e64 _PyFunction_Vectorcall + 240
      23  python3.9                           0x00000001025a3468 _PyObject_FastCallDictTstate + 320
      24  python3.9                           0x00000001025a41e0 _PyObject_Call_Prepend + 164
      25  python3.9                           0x000000010261dbb4 slot_tp_init + 380
      26  python3.9                           0x000000010262c658 type_call + 344
      27  python3.9                           0x00000001025a31e8 _PyObject_MakeTpCall + 340
      28  python3.9                           0x00000001026b36ac call_function + 724
      29  python3.9                           0x00000001026afdc4 _PyEval_EvalFrameDefault + 29396
      30  python3.9                           0x00000001025a3ee4 function_code_fastcall + 116
      31  python3.9                           0x00000001026b3614 call_function + 572
      32  python3.9                           0x00000001026afdc4 _PyEval_EvalFrameDefault + 29396
      33  python3.9                           0x00000001025a3ee4 function_code_fastcall + 116
      34  python3.9                           0x00000001026b3614 call_function + 572
      35  python3.9                           0x00000001026afd44 _PyEval_EvalFrameDefault + 29268
      36  python3.9                           0x00000001026a84a8 _PyEval_EvalCode + 2968
      37  python3.9                           0x00000001025a3e64 _PyFunction_Vectorcall + 240
      38  python3.9                           0x00000001026b3614 call_function + 572
      39  python3.9                           0x00000001026afd44 _PyEval_EvalFrameDefault + 29268
      40  python3.9                           0x00000001026a84a8 _PyEval_EvalCode + 2968
      41  python3.9                           0x00000001025a3e64 _PyFunction_Vectorcall + 240
      42  python3.9                           0x00000001025a3468 _PyObject_FastCallDictTstate + 320
      43  python3.9                           0x00000001025a41e0 _PyObject_Call_Prepend + 164
      44  python3.9                           0x000000010261dbb4 slot_tp_init + 380
      45  python3.9                           0x000000010262c658 type_call + 344
      46  python3.9                           0x00000001025a31e8 _PyObject_MakeTpCall + 340
      47  python3.9                           0x00000001026b36ac call_function + 724
      48  python3.9                           0x00000001026afdc4 _PyEval_EvalFrameDefault + 29396
      49  python3.9                           0x00000001026a84a8 _PyEval_EvalCode + 2968
      50  python3.9                           0x00000001025a3e64 _PyFunction_Vectorcall + 240
      51  python3.9                           0x00000001026b3614 call_function + 572
      52  python3.9                           0x00000001026afd28 _PyEval_EvalFrameDefault + 29240
      53  python3.9                           0x00000001026a84a8 _PyEval_EvalCode + 2968
      54  python3.9                           0x00000001025a3e64 _PyFunction_Vectorcall + 240
      55  python3.9                           0x00000001026b0078 _PyEval_EvalFrameDefault + 30088
      56  python3.9                           0x00000001026a84a8 _PyEval_EvalCode + 2968
      57  python3.9                           0x00000001025a3e64 _PyFunction_Vectorcall + 240
      58  python3.9                           0x00000001026b3614 call_function + 572
      59  python3.9                           0x00000001026afd44 _PyEval_EvalFrameDefault + 29268
      60  python3.9                           0x00000001026a84a8 _PyEval_EvalCode + 2968
      61  python3.9                           0x00000001026a3020 builtin_exec + 1032
      62  python3.9                           0x00000001025f827c cfunction_vectorcall_FASTCALL + 208
      63  python3.9                           0x00000001026b3614 call_function + 572
      64  python3.9                           0x00000001026afdc4 _PyEval_EvalFrameDefault + 29396
      65  python3.9                           0x00000001025ba04c gen_send_ex + 532
      66  python3.9                           0x00000001026ac37c _PyEval_EvalFrameDefault + 14476
      67  python3.9                           0x00000001025ba04c gen_send_ex + 532
      68  python3.9                           0x00000001026ac37c _PyEval_EvalFrameDefault + 14476
      69  python3.9                           0x00000001025ba04c gen_send_ex + 532
      70  python3.9                           0x00000001025b0cbc method_vectorcall_O + 160
      71  python3.9                           0x00000001026b3614 call_function + 572
      72  python3.9                           0x00000001026afd28 _PyEval_EvalFrameDefault + 29240
      73  python3.9                           0x00000001025a3ee4 function_code_fastcall + 116
      74  python3.9                           0x00000001026b3614 call_function + 572
      75  python3.9                           0x00000001026afdc4 _PyEval_EvalFrameDefault + 29396
      76  python3.9                           0x00000001025a3ee4 function_code_fastcall + 116
      77  python3.9                           0x00000001026b3614 call_function + 572
      78  python3.9                           0x00000001026afd28 _PyEval_EvalFrameDefault + 29240
      79  python3.9                           0x00000001026a84a8 _PyEval_EvalCode + 2968
      80  python3.9                           0x00000001025a3e64 _PyFunction_Vectorcall + 240
      81  python3.9                           0x00000001025a6cf0 method_vectorcall + 164
      82  python3.9                           0x00000001026b3614 call_function + 572
      83  python3.9                           0x00000001026afe40 _PyEval_EvalFrameDefault + 29520
      84  python3.9                           0x00000001025a3ee4 function_code_fastcall + 116
      85  python3.9                           0x00000001026b3614 call_function + 572
      86  python3.9                           0x00000001026afd28 _PyEval_EvalFrameDefault + 29240
      87  python3.9                           0x00000001025a3ee4 function_code_fastcall + 116
      88  python3.9                           0x00000001026b3614 call_function + 572
      89  python3.9                           0x00000001026afd28 _PyEval_EvalFrameDefault + 29240
      90  python3.9                           0x00000001025a3ee4 function_code_fastcall + 116
      91  python3.9                           0x00000001026b3614 call_function + 572
      92  python3.9                           0x00000001026afd28 _PyEval_EvalFrameDefault + 29240
      93  python3.9                           0x00000001026a84a8 _PyEval_EvalCode + 2968
      94  python3.9                           0x00000001025a3e64 _PyFunction_Vectorcall + 240
      95  python3.9                           0x00000001025a6cf0 method_vectorcall + 164
      96  python3.9                           0x00000001025a3a5c PyVectorcall_Call + 156
      97  python3.9                           0x00000001026b0078 _PyEval_EvalFrameDefault + 30088
      98  python3.9                           0x00000001026a84a8 _PyEval_EvalCode + 2968
      99  python3.9                           0x00000001025a3e64 _PyFunction_Vectorcall + 240
      100 python3.9                           0x00000001026b3614 call_function + 572
      101 python3.9                           0x00000001026afdc4 _PyEval_EvalFrameDefault + 29396
      102 python3.9                           0x00000001026a84a8 _PyEval_EvalCode + 2968
      103 python3.9                           0x000000010270b834 pyrun_file + 376
      104 python3.9                           0x000000010270ad48 PyRun_SimpleFileExFlags + 816
      105 python3.9                           0x000000010272de84 Py_RunMain + 2916
      106 python3.9                           0x000000010272f018 pymain_main + 1272
      107 python3.9                           0x0000000102549ddc main + 56
      108 dyld                                0x0000000102a75088 start + 516
  )
  libc++abi: terminating with uncaught exception of type NSException
  Abort trap: 6
  </code></pre>
  <p>Just a call to <code>tkinter.Tk()</code> gives the same. I get the same if I use <code>python --gui 'tk'</code>. Any idea how to solve or at least debug this?</p>
  <p><strong>Edit:</strong><br />
  I just found <a href="https://stackoverflow.com/questions/43066073/matplotlib-tkinter-opencv-crashing-in-python-3">this answer</a> which reminded me that I import <code>matplotlib.pyplot</code> upon the startup of <code>ipython</code>. Turning this off fixed it. But if someone can elaborate why this is or how to <em>really</em> fix it, that would be greatly appreciated!</p>