-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: crash due to backend issue in ipython session started explicitly with InteractiveShell #23770
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
Comments
The source of the problem is that we by default try to pick the "best" backend and use that. If you have an active X session and a GUI framework installed we will select that. In order for the GUI window to be responsive someone needs to take care of running the GUI event loop while waiting for the human to type into the terminal. What The immediate work around is to either force the backend to be non-interactive [2] via
(svg and pdf would also work, pick the one that matches the type you expect to save most often). If you want to have GUI integration then you need to launch one of the sub-classes of Medium term, we should catch errors in the call to I am going to label this as good first issue and medium difficulty. There is no API design involved here (we have a reproduction case that should not fail), but the backend selection code / fallback logic in
The relevant code: matplotlib/lib/matplotlib/pyplot.py Lines 210 to 329 in 07af522
[1] : more details than anyone wants about input hooks: https://matplotlib.org/stable/users/explain/interactive_guide.html |
Thanks! This all makes sense. For posterity / future googling: I discovered this issue because |
I can try to take this issue! if you guys would guide me |
@nithinivi Do you have specific questions about #23770 (comment) ? |
@tacaswell I'm working from a windows laptop, and I was able to reproduce the error, Is there something is should specifically consider while developing windows? so sorry for the late reply ! :) |
No, I do not think that this issue is platform specific. |
Hi! It seems that this issue is still around (tried and got it on windows, at least). |
Hi, @tacaswell! I had a couple questions regarding this issue. So far I changed the code so that it looks like this in the "switch_backend()" method:
and like this in the "install_repl_displayhook()" method:
I tried running the original prompt in the terminal -- nothing happened, but there were no error messages except for the logger output.
It seems to be working with my changes (but unable to load the icons, even though the menus themselves are functional). However -- the backend this defaulted to is GTK4Agg. In your comment you said that we should be defaulting to a non-interactive backend. Plus the code mentions that it's not ideal since it's cairo-based:
but after qtagg "fails", the next two backends are cairo-based.
The issue with icons only appeared for gtk4 and gtk3. I also got an additional failed test after making these changes:
This is my first issue so it's very likely that I misunderstood something, but I still wanted to ask.
Thanks in advance :) |
Hi @turnipseason, as there's no active open PR, you're welcome to open one. For 3, you may want to do a build clean and then rebuild matplotlib. |
we also have If you commit your changes it will work (we write the version Matpltolib used to generate the pickle into the file and then check if it matches the current version on the way out, the reported version of Matpltolib depends on the current state of git). |
Thanks for replying and the clarification! I'll check everything once again and try submitting a PR in the morning then :) |
Bug summary
If an IPython session is started via
IPython.core.interactiveshell.InteractiveShell.instance()
, trying to create a matplotlib figure, or even query the backend, produces a crash (stack trace below) on OS X, and on Linux if there is an active X11 session.Without an X session on Linux or if ipython is started via the command-line
ipython
command, everything works as expected.Code for reproduction
Actual outcome
Expected outcome
Additional information
The below is sufficient to reproduce the crash from a clean environment.
It's a weird corner case to be creating an ipython session this way, and perhaps the problem is on my end, but I wasn't expecting a crash like this regardless...
Operating system
macOS, Linux, maybe windows too?
Matplotlib Version
3.5.3
Matplotlib Backend
this crashes too with the same error when invoked after starting
InteractiveShell.instance()
Python version
3.10.6 (but also occurs with various 3.9 versions)
Jupyter version
No response
Installation
conda
The text was updated successfully, but these errors were encountered: