Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%matplotlib osx crashses #1124

Open
Carreau opened this issue Jun 12, 2023 · 3 comments
Open

%matplotlib osx crashses #1124

Carreau opened this issue Jun 12, 2023 · 3 comments

Comments

@Carreau
Copy link
Member

Carreau commented Jun 12, 2023

See jupyter/jupyter_console#294 and jupyterlab/jupyterlab#14653

Original reporter is @ubaldot

Output of %matplotlib osx gives the following error message:

2023-05-03 19:46:24.850 python[46916:7042851] *** Assertion failure in +[NSEvent otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:], NSEvent.m:647
2023-05-03 19:46:24.852 python[46916:7042851] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: _NSEventMask64FromType(type) & WeirdMask'
*** First throw call stack:
(
	0   CoreFoundation                      0x00000001aa69319c __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x00000001aa1b24d4 objc_exception_throw + 60
	2   Foundation                          0x00000001ab645b88 -[NSCalendarDate initWithCoder:] + 0
	3   AppKit                              0x00000001ad9dad50 +[NSEvent otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:] + 264
	4   libffi.8.dylib                      0x0000000105ac404c ffi_call_SYSV + 76
	5   libffi.8.dylib                      0x0000000105ac1790 ffi_call_int + 1256
	6   _ctypes.cpython-310-darwin.so       0x0000000105aa4a30 _ctypes_callproc + 1324
	7   _ctypes.cpython-310-darwin.so       0x0000000105a9ebf8 PyCFuncPtr_call + 1160
	8   python3.10                          0x0000000104ed2294 _PyObject_MakeTpCall + 612
	9   python3.10                          0x0000000104fc10f0 call_function + 676
	10  python3.10                          0x0000000104fbce58 _PyEval_EvalFrameDefault + 26500
	11  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	12  python3.10                          0x0000000104fc1058 call_function + 524
	13  python3.10                          0x0000000104fbce58 _PyEval_EvalFrameDefault + 26500
	14  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	15  _ctypes.cpython-310-darwin.so       0x0000000105aa2e0c closure_fcn + 644
	16  libffi.8.dylib                      0x0000000105ac1b6c ffi_closure_SYSV_inner + 796
	17  libffi.8.dylib                      0x0000000105ac41d4 ffi_closure_SYSV + 52
	18  CoreFoundation                      0x00000001aa63448c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32
	19  CoreFoundation                      0x00000001aa634134 __CFRunLoopDoTimer + 940
	20  CoreFoundation                      0x00000001aa633c8c __CFRunLoopDoTimers + 356
	21  CoreFoundation                      0x00000001aa61941c __CFRunLoopRun + 1852
	22  CoreFoundation                      0x00000001aa61858c CFRunLoopRunSpecific + 612
	23  HIToolbox                           0x00000001b3e4ddf4 RunCurrentEventLoopInMode + 292
	24  HIToolbox                           0x00000001b3e4dc30 ReceiveNextEventCommon + 648
	25  HIToolbox                           0x00000001b3e4d988 _BlockUntilNextEventMatchingListInModeWithFilter + 76
	26  AppKit                              0x00000001ad837f58 _DPSNextEvent + 636
	27  AppKit                              0x00000001ad8370f4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
	28  AppKit                              0x00000001ad82b558 -[NSApplication run] + 464
	29  libffi.8.dylib                      0x0000000105ac404c ffi_call_SYSV + 76
	30  libffi.8.dylib                      0x0000000105ac1790 ffi_call_int + 1256
	31  _ctypes.cpython-310-darwin.so       0x0000000105aa4a30 _ctypes_callproc + 1324
	32  _ctypes.cpython-310-darwin.so       0x0000000105a9ebf8 PyCFuncPtr_call + 1160
	33  python3.10                          0x0000000104ed2294 _PyObject_MakeTpCall + 612
	34  python3.10                          0x0000000104fc10f0 call_function + 676
	35  python3.10                          0x0000000104fbce58 _PyEval_EvalFrameDefault + 26500
	36  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	37  python3.10                          0x0000000104fc1058 call_function + 524
	38  python3.10                          0x0000000104fbce58 _PyEval_EvalFrameDefault + 26500
	39  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	40  python3.10                          0x0000000104fc1058 call_function + 524
	41  python3.10                          0x0000000104fbce58 _PyEval_EvalFrameDefault + 26500
	42  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	43  python3.10                          0x000000010506ab04 partial_vectorcall + 396
	44  python3.10                          0x0000000104fc1058 call_function + 524
	45  python3.10                          0x0000000104fbce58 _PyEval_EvalFrameDefault + 26500
	46  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	47  python3.10                          0x0000000104ed5aac method_vectorcall + 516
	48  python3.10                          0x0000000104fd9b78 context_run + 348
	49  python3.10                          0x0000000104f258a8 cfunction_vectorcall_FASTCALL_KEYWORDS + 112
	50  python3.10                          0x0000000104fbd160 _PyEval_EvalFrameDefault + 27276
	51  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	52  python3.10                          0x0000000104fc1058 call_function + 524
	53  python3.10                          0x0000000104fbcdc0 _PyEval_EvalFrameDefault + 26348
	54  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	55  python3.10                          0x0000000104fc1058 call_function + 524
	56  python3.10                          0x0000000104fbcdc0 _PyEval_EvalFrameDefault + 26348
	57  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	58  python3.10                          0x0000000104fc1058 call_function + 524
	59  python3.10                          0x0000000104fbcdc0 _PyEval_EvalFrameDefault + 26348
	60  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	61  python3.10                          0x0000000104fc1058 call_function + 524
	62  python3.10                          0x0000000104fbcdc0 _PyEval_EvalFrameDefault + 26348
	63  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	64  python3.10                          0x0000000104fc1058 call_function + 524
	65  python3.10                          0x0000000104fbcdc0 _PyEval_EvalFrameDefault + 26348
	66  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	67  python3.10                          0x0000000104ed594c method_vectorcall + 164
	68  python3.10                          0x0000000104fc1058 call_function + 524
	69  python3.10                          0x0000000104fbcde8 _PyEval_EvalFrameDefault + 26388
	70  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	71  python3.10                          0x0000000104fb5590 PyEval_EvalCode + 120
	72  python3.10                          0x0000000104fb1108 builtin_exec + 836
	73  python3.10                          0x0000000104f259e4 cfunction_vectorcall_FASTCALL + 200
	74  python3.10                          0x0000000104fc1058 call_function + 524
	75  python3.10                          0x0000000104fbce58 _PyEval_EvalFrameDefault + 26500
	76  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	77  python3.10                          0x0000000104fc1058 call_function + 524
	78  python3.10                          0x0000000104fbce58 _PyEval_EvalFrameDefault + 26500
	79  python3.10                          0x0000000104fb5dc8 _PyEval_Vector + 2056
	80  python3.10                          0x0000000105035164 pymain_run_module + 272
	81  python3.10                          0x00000001050347a0 Py_RunMain + 1584
	82  python3.10                          0x0000000105035c50 pymain_main + 1272
	83  python3.10                          0x0000000104e7c00c main + 56
	84  dyld                                0x00000001aa1e3f28 start + 2236
)
libc++abi: terminating due to uncaught exception of type NSException
/Users/ubaldot/opt/miniconda3/envs/myenv/lib/python3.10/site-packages/jupyter_console/ptshell.py:787: UserWarning: The kernel did not respond to an is_complete_request. Setting `use_kernel_is_complete` to False.
  warn('The kernel did not respond to an is_complete_request. '

I tried to run %matplotlib` both in a IPython and a Jupyter console, getting the following outputs:

  • Using matplotlib backend: MacOSX (IPython)
  • Using matplotlib backend: <object object at 0x104853730> (Jupyter console)

the consequence is that plots in IPython are interactive whereas plots in Jupyter console are rendered as a simple .png.
Example code follows if you want to test:

import matplotlib.pyplot as plt
import matplotlib
x = list(range(1,5))
y = list(map(lambda x: x**2, x))
plt.plot(x,y)

I am running Jupyter console 6.6.3, Python 3.10.8, IPython 8.12.0 with pyqt 5.51.7 installed through conda on Mac Os Ventura.

@ianthomas23
Copy link
Collaborator

This is still a problem on an M3 running Sonoma 14.4.1 and Python 3.12.3, IPython 8.23.0, ipykernel 6.29.4 and Matplotlib 3.8.4. Using %matplotlib osx in IPython works fine, but the same in Jupyter console, qtconsole, notebook or spyder gives the exception reported previously. Using import matplotlib as mpl; mpl.use("macosx") in these projects works as expected. So it does indeed appear to be a problem relating to the osx event-loop integration in ipykernel.

@ivanlen
Copy link

ivanlen commented May 13, 2024

Same problem here:

  • M3
  • Sonoma 14.4.1
  • Python 3.11.9
  • iPython 8.24.0
  • matplotlib 3.8.4
  • ipykernel 6.29.3

@ianthomas23
Copy link
Collaborator

@ivanlen Note there is a fix for this in #1237.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants