[Bug]: Using an ipython config of `InteractiveShellApp.matplotlib='inline'` fails on macos for `matplotlib>3.9.0` · Issue #28855 · matplotlib/matplotlib · GitHub
[Bug]: Using an ipython config of InteractiveShellApp.matplotlib='inline' fails on macos for matplotlib>3.9.0 #28855
I am using a Jupyter notebook in VS Code Version: 1.93.1. on MacOS Ventura 13.4.1 and Python 3.12.5
With matplotlib<=3.9.0, I can plot visualizations inline within VS Code. The reported backend is by default inline and everything is fine.
Starting with version 3.9.1, the default backend apparently switched to macosx. When I try to plot something now, a new Python window pops up, but no plot is created unless I add plt.show().
Is this the intended behavior? It breaks essentially all of my notebooks because I would have to go in and add %matplotlib inline to make things work again.
This is not intended, the default matplotib backend in JupyterLab and Notebook should still be the inline backend.
I cannot reproduce this using a new virtual environment on Sonoma 14.6.1 with Python 3.12.6, Matplotlib 3.9.2 and VSCode 1.93.1. Here's my output:
I note that for matplotlib.get_backend() you get the short name inline whereas I get the fully qualified module://matplotlib_inline.backend_inline although the former is shorthand for the latter so may not be significant. But it is a clue.
I think you are using an unusually old versions of the jupyter packages compared to latest matplotlib. ipykernel and ipython are probably the key ones. This is what I have in my new env:
If by a Jupyter version of 6.5.1 you mean the version of notebook then that is from October 2022 and if you have a similar age of ipykernel and ipython I wouldn't be surprised at some strange results.
Can you do two things?
Run jupyter --version and post your output here, then we can see exactly what versions of the important packages you are using.
Create new virtual environment and install recent packages (matplotlib and notebook may be enough). I think this should work fine for you.
The reported backend is macosx, and the behavior is as described above. In addition, I am getting the following message in the ServerApp log when running the plt.plot command:
[IPKernelApp] WARNING | GUI event loop or pylab initialization failed
Downgrading to 3.9.0 also fixes the behavior, just like from within VS Code.
Matplotlib 3.9.0 is about the right time for things to break with backends as there was a major refactor to move IPython's management of backends to Matplotlib where it more correctly belongs. #27948 was the PR on the Matplotlib side for this, and there were a few glitches fixed later such as #28332 and ipython/ipython#14451.
But as I cannot reproduce the problem it is somewhat difficult to understand it. What it feels like now (and I have been wrong before 😄) is that you have some overriding of the default Matplotlib backend somewhere such as an environment variable or rcParams, or some preamble code that is run when you start a kernel or notebook which does some backend setting or manipulation. There have been occasions where Jupyter extensions have done something like this (though not to Matplotlib as far as I know) and their forced changes have affected things they shouldn't.
If it was my mac, what I would try next is to create a new user who therefore doesn't have any Matplotlib or Jupyter configuration set up, create a venv for them and re-try the test.
I suppose we should also consider that although we are both using the same package versions, we are using different python installations. I'm using mamba and I guess you are using homebrew? The difference here may be important perhaps in regard to the venvs being fully isolated or not.
Oh wow, I am so sorry for having you chase this down. I found the culprit:
I remembered that a long time ago I wanted the default figure format to be SVG, so I created a file ~/.ipython/profile_default/ipython_kernel_config.py and put the following in it:
I am glad we have found the actual bug. It is a bug, it should still work but it is an unusual thing to do as the methods of rendering that support the inline backend already have it as their default, so it should essentially be a no-op.
It will need fixing, but isn't urgent as this is definitely a corner case. I will change the title of this issue to reflect what the problem really is.
I don't have any suggestions for making SVG the default. I would never do that as there are some things that SVG does not render well such as some color gradients. And I pretty much always use the ipympl backend rather than inline as it is interactive.
changed the title [-][Bug]: `macosx` backend is default in `matplotlib>3.9.0`, breaks plots in VS Code[/-][+][Bug]: Using an ipython config of `InteractiveShellApp.matplotlib='inline'` fails on macos backend for `matplotlib>3.9.0`[/+]on Sep 24, 2024
@QuLogic Thanks, I will try the rcParams._get in matplotlib-inline. I'll need to do some comprehensive manual testing to clarify in ipython integration is affected by this.
Activity
tacaswell commented on Sep 20, 2024
@ianthomas23 This is probably more fallout from moving the backend mappings around?
ianthomas23 commented on Sep 21, 2024
This is not intended, the default matplotib backend in JupyterLab and Notebook should still be the inline backend.
I cannot reproduce this using a new virtual environment on Sonoma 14.6.1 with Python 3.12.6, Matplotlib 3.9.2 and VSCode 1.93.1. Here's my output:

I note that for matplotlib.get_backend() you get the short name inline whereas I get the fully qualified module://matplotlib_inline.backend_inline although the former is shorthand for the latter so may not be significant. But it is a clue.
I think you are using an unusually old versions of the jupyter packages compared to latest matplotlib. ipykernel and ipython are probably the key ones. This is what I have in my new env:
If by a Jupyter version of 6.5.1 you mean the version of notebook then that is from October 2022 and if you have a similar age of ipykernel and ipython I wouldn't be surprised at some strange results.
Can you do two things?
Run jupyter --version and post your output here, then we can see exactly what versions of the important packages you are using.
Create new virtual environment and install recent packages (matplotlib and notebook may be enough). I think this should work fine for you.
Simon-Stone commented on Sep 21, 2024
Thanks for engaging with this.
I created a fresh virtual environment and used it for what I described above. Here is the output of jupyter --version:
I then ran pip install notebook, and now jupyter --version reports:
The error is still exactly the same, with the same reported backends.
ianthomas23 commented on Sep 23, 2024
OK, let's try removing VSCode from the workflow. Can you use jupyter lab or jupyter notebook to run the test code in a browser?
Simon-Stone commented on Sep 23, 2024
Good thinking. Here is what I did:
The reported backend is macosx, and the behavior is as described above. In addition, I am getting the following message in the ServerApp log when running the plt.plot command:
Downgrading to 3.9.0 also fixes the behavior, just like from within VS Code.
ianthomas23 commented on Sep 23, 2024
The warning comes from here:
https://github.com/ipython/ipython/blob/68a3854c3e582de0e29dba22f483729c01c6f38b/IPython/core/shellapp.py#L297
The next line shows a traceback, can you copy and paste that from the logs too?
Simon-Stone commented on Sep 23, 2024
Small correction: The warning appears every time the kernel is restarted.
Weirdly, there is no traceback. Here is the output from a couple of kernel restarts:
ianthomas23 commented on Sep 23, 2024
I am running out of ideas here.
Matplotlib 3.9.0 is about the right time for things to break with backends as there was a major refactor to move IPython's management of backends to Matplotlib where it more correctly belongs. #27948 was the PR on the Matplotlib side for this, and there were a few glitches fixed later such as #28332 and ipython/ipython#14451.
But as I cannot reproduce the problem it is somewhat difficult to understand it. What it feels like now (and I have been wrong before 😄) is that you have some overriding of the default Matplotlib backend somewhere such as an environment variable or rcParams, or some preamble code that is run when you start a kernel or notebook which does some backend setting or manipulation. There have been occasions where Jupyter extensions have done something like this (though not to Matplotlib as far as I know) and their forced changes have affected things they shouldn't.
If it was my mac, what I would try next is to create a new user who therefore doesn't have any Matplotlib or Jupyter configuration set up, create a venv for them and re-try the test.
I suppose we should also consider that although we are both using the same package versions, we are using different python installations. I'm using mamba and I guess you are using homebrew? The difference here may be important perhaps in regard to the venvs being fully isolated or not.
Simon-Stone commented on Sep 23, 2024
Oh wow, I am so sorry for having you chase this down. I found the culprit:
I remembered that a long time ago I wanted the default figure format to be SVG, so I created a file ~/.ipython/profile_default/ipython_kernel_config.py and put the following in it:
c.InteractiveShellApp.matplotlib = 'inline' c.InlineBackend.figure_formats = {'svg'}I removed it just now, and everything works as expected with >3.9.0!
Again, so sorry for this coming back to "user error".
I am curious, though, if you know why this breaks after 3.9.0, and if you had a different suggestion to globally make SVG the default format?
ianthomas23 commented on Sep 24, 2024
I am glad we have found the actual bug. It is a bug, it should still work but it is an unusual thing to do as the methods of rendering that support the inline backend already have it as their default, so it should essentially be a no-op.
It will need fixing, but isn't urgent as this is definitely a corner case. I will change the title of this issue to reflect what the problem really is.
I don't have any suggestions for making SVG the default. I would never do that as there are some things that SVG does not render well such as some color gradients. And I pretty much always use the ipympl backend rather than inline as it is interactive.
3 remaining items
QuLogic commented on Oct 10, 2024
It does make sense to use rcParams._get if backend selection is to be avoided. I'm just uncertain how IPython integration will be enabled if https://github.com/ipython/matplotlib-inline/blob/90034cf74d7e5a6dea54b9d8f148427450354c45/matplotlib_inline/backend_inline.py#L214 sees the 'unset-backend' sentinel value at import time (and there appear to be no other callers.) I suppose this is something to figure out in matplotlib-inline for the (potential) PR?
ianthomas23 commented on Oct 10, 2024
@QuLogic Thanks, I will try the rcParams._get in matplotlib-inline. I'll need to do some comprehensive manual testing to clarify in ipython integration is affected by this.
ksunden commented on Jul 25, 2025
Just noting here that there was a PR at least partially addressing this over in ipython/matplotlib-inline#38
Is there any further action to take in this repo, or should this be closed out here?
tacaswell commented on Jul 25, 2025
I think this is handled on the maptoltlib-inline side. Closing for now, please ping to re-open if I am confused.