ipython: python crashes when importing matplotlib in terminal mode on m1 mac

Hello community,

I am experiencing the following crash when trying to plot from the command line on my M1 mac:

(base) ➜  ~ ipython
Python 3.9.1 | packaged by conda-forge | (default, Jan 26 2021, 01:30:54) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.20.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import matplotlib

In [2]: matplotlib.get_backend()
Out[2]: 'MacOSX'

In [3]: [1]    2797 bus error  ipython

Even more weird, if I try to set any value of c.InteractiveShellApp.matplotlib in the ipython_config.py, the crash occurs instantly (that is, when ipython starts). In “vanilla” python REPL, everything works as expected.

My ipython (7.20.0) and matplotlib (3.3.4) are installed through conda and this is otherwise a “fresh” install.

Any help is appreciated!

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (11 by maintainers)

Most upvoted comments

😄 we’ve got a DTK at conda-forge (which you are welcome to have access to).

You know it’s no good when @isuruf somehow gets in your computer…

Here’s a backtrace,

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x10792c460)
  * frame #0: 0x000000010792c460
    frame #1: 0x00000001a26aa2f0 CoreFoundation`CFFileDescriptorInvalidate + 308
    frame #2: 0x00000001aef90050 libffi.dylib`ffi_call_SYSV + 80
    frame #3: 0x00000001aef989d8 libffi.dylib`ffi_call_int + 944
    frame #4: 0x000000010797876c _ctypes.cpython-39-darwin.so`_ctypes_callproc + 1236
    frame #5: 0x0000000107972b90 _ctypes.cpython-39-darwin.so`PyCFuncPtr_call + 1196
    frame #6: 0x00000001000600b8 python`_PyObject_MakeTpCall + 340
    frame #7: 0x0000000100168c00 python`call_function + 724
    frame #8: 0x0000000100165318 python`_PyEval_EvalFrameDefault + 29396
    frame #9: 0x0000000100060dc4 python`function_code_fastcall + 116
    frame #10: 0x0000000107976b90 _ctypes.cpython-39-darwin.so`closure_fcn + 648
    frame #11: 0x00000001aef98e10 libffi.dylib`ffi_closure_SYSV_inner + 800
    frame #12: 0x00000001aef901e8 libffi.dylib`ffi_closure_SYSV + 56
    frame #13: 0x00000001a26970f8 CoreFoundation`__CFFileDescriptorPerform + 356
    frame #14: 0x00000001a262bc04 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
    frame #15: 0x00000001a262bb50 CoreFoundation`__CFRunLoopDoSource0 + 208
    frame #16: 0x00000001a262b83c CoreFoundation`__CFRunLoopDoSources0 + 268
    frame #17: 0x00000001a262a1d4 CoreFoundation`__CFRunLoopRun + 824
    frame #18: 0x00000001a2629730 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #19: 0x00000001aa132f0c HIToolbox`RunCurrentEventLoopInMode + 292
    frame #20: 0x00000001aa132bcc HIToolbox`ReceiveNextEventCommon + 320
    frame #21: 0x00000001aa132a6c HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 76
    frame #22: 0x00000001a4dfedb0 AppKit`_DPSNextEvent + 868
    frame #23: 0x00000001a4dfd730 AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1312
    frame #24: 0x00000001a4def58c AppKit`-[NSApplication run] + 600
    frame #25: 0x00000001aef90050 libffi.dylib`ffi_call_SYSV + 80
    frame #26: 0x00000001aef989d8 libffi.dylib`ffi_call_int + 944
    frame #27: 0x000000010797876c _ctypes.cpython-39-darwin.so`_ctypes_callproc + 1236
    frame #28: 0x0000000107972b90 _ctypes.cpython-39-darwin.so`PyCFuncPtr_call + 1196
    frame #29: 0x00000001000600b8 python`_PyObject_MakeTpCall + 340
    frame #30: 0x0000000100168c00 python`call_function + 724
    frame #31: 0x0000000100165318 python`_PyEval_EvalFrameDefault + 29396
    frame #32: 0x0000000100060dc4 python`function_code_fastcall + 116
    frame #33: 0x0000000100168b68 python`call_function + 572
    frame #34: 0x0000000100165298 python`_PyEval_EvalFrameDefault + 29268
    frame #35: 0x000000010015d9fc python`_PyEval_EvalCode + 2968
    frame #36: 0x0000000100060d44 python`_PyFunction_Vectorcall + 240
    frame #37: 0x0000000100168b68 python`call_function + 572
    frame #38: 0x000000010016527c python`_PyEval_EvalFrameDefault + 29240
    frame #39: 0x0000000100060dc4 python`function_code_fastcall + 116
    frame #40: 0x0000000100168b68 python`call_function + 572
    frame #41: 0x000000010016527c python`_PyEval_EvalFrameDefault + 29240
    frame #42: 0x0000000100060dc4 python`function_code_fastcall + 116
    frame #43: 0x0000000100168b68 python`call_function + 572
    frame #44: 0x000000010016527c python`_PyEval_EvalFrameDefault + 29240
    frame #45: 0x0000000100060dc4 python`function_code_fastcall + 116
    frame #46: 0x0000000100168b68 python`call_function + 572
    frame #47: 0x000000010016527c python`_PyEval_EvalFrameDefault + 29240
    frame #48: 0x000000010015d9fc python`_PyEval_EvalCode + 2968
    frame #49: 0x0000000100060d44 python`_PyFunction_Vectorcall + 240
    frame #50: 0x0000000100063bc0 python`method_vectorcall + 164
    frame #51: 0x0000000100168b68 python`call_function + 572
    frame #52: 0x0000000100165394 python`_PyEval_EvalFrameDefault + 29520
    frame #53: 0x000000010015d9fc python`_PyEval_EvalCode + 2968
    frame #54: 0x0000000100060d44 python`_PyFunction_Vectorcall + 240
    frame #55: 0x0000000100063bc0 python`method_vectorcall + 164
    frame #56: 0x000000010006093c python`PyVectorcall_Call + 156
    frame #57: 0x00000001001655cc python`_PyEval_EvalFrameDefault + 30088
    frame #58: 0x0000000100060dc4 python`function_code_fastcall + 116
    frame #59: 0x0000000100168b68 python`call_function + 572
    frame #60: 0x000000010016527c python`_PyEval_EvalFrameDefault + 29240
    frame #61: 0x000000010015d9fc python`_PyEval_EvalCode + 2968
    frame #62: 0x0000000100060d44 python`_PyFunction_Vectorcall + 240
    frame #63: 0x0000000100168b68 python`call_function + 572
    frame #64: 0x000000010016527c python`_PyEval_EvalFrameDefault + 29240
    frame #65: 0x000000010015d9fc python`_PyEval_EvalCode + 2968
    frame #66: 0x0000000100060d44 python`_PyFunction_Vectorcall + 240
    frame #67: 0x0000000100168b68 python`call_function + 572
    frame #68: 0x000000010016527c python`_PyEval_EvalFrameDefault + 29240
    frame #69: 0x0000000100060dc4 python`function_code_fastcall + 116
    frame #70: 0x0000000100168b68 python`call_function + 572
    frame #71: 0x000000010016527c python`_PyEval_EvalFrameDefault + 29240
    frame #72: 0x000000010015d9fc python`_PyEval_EvalCode + 2968
    frame #73: 0x0000000100060d44 python`_PyFunction_Vectorcall + 240
    frame #74: 0x0000000100063bc0 python`method_vectorcall + 164
    frame #75: 0x000000010006093c python`PyVectorcall_Call + 156
    frame #76: 0x00000001001655cc python`_PyEval_EvalFrameDefault + 30088
    frame #77: 0x000000010015d9fc python`_PyEval_EvalCode + 2968
    frame #78: 0x0000000100060d44 python`_PyFunction_Vectorcall + 240
    frame #79: 0x0000000100168b68 python`call_function + 572
    frame #80: 0x0000000100165318 python`_PyEval_EvalFrameDefault + 29396
    frame #81: 0x000000010015d9fc python`_PyEval_EvalCode + 2968
    frame #82: 0x00000001001c0ed0 python`PyRun_FileExFlags + 464
    frame #83: 0x00000001001c01ac python`PyRun_SimpleFileExFlags + 436
    frame #84: 0x00000001001e2fc4 python`Py_RunMain + 2916
    frame #85: 0x00000001001e4138 python`pymain_main + 1256
    frame #86: 0x0000000100007520 python`main + 56
    frame #87: 0x00000001a254cf54 libdyld.dylib`start + 4

Checking in to say that the problem is fixed! Again, thanks a million guys. You the best🥇

Not to steal the thunder of fixing this upstream, but we just merged a patch for conda-forge:

https://github.com/conda-forge/ipython-feedstock/pull/129

Builds are up, but might take a bit until they are available on CDN. @erykoff has tested it locally, but if @eugene can check it out and (hopefully) close that would be great.

Thanks all!

This is the fastest response and an example of legendary cooperation. I love this community

⭐ ⭐ ⭐ ⭐ ⭐ would recommend.

❤️💎👐

matplotlib was a red herring. The problem was in ipython, this PR fixes the crash: https://github.com/ipython/ipython/pull/12804

woof, what a brutal thing to do between a developer and their machine.

but for real, posting a link to a gist of all of conda list --explicit (or putting it in <details><pre></pre></details>) is actually what we’d need to do anything more than cosmetic.

Unfortunately, we don’t have any resources to do native testing on this platform combination. You might need to get friendly with strace (if there is such a thing on osx) to provide more information.

  • do you get the same error with another ipython, e.g. 7.19?
  • do you get the same error with another python, e.g. 3.8?

In the meanwhile, a full conda list --explicit might help point some stuff out.