I've been working on the GUI event loop hooks in IPython, and while working on this issue, I realized that importing backend_inline will trigger matplotlib's "auto backend selection". In many systems, this results in selecting QtAgg and thus in IPython, this effectively calls %gui qt.
The issue is that 'qt' as far as GUI event loop hooks go implies "latest version of Qt", and once a version of Qt is imported in a session, you can't change it. So on a system with e.g. pyside6 and PyQt5 installed, starting IPython with --matplotlib=qt5 will result in an effective %gui qt call, which will import pyside6, followed by a %gui qt5 call, which will refuse to run because it cannot import PyQt5.
The culprit is this:
I believe that should instead call _get_backend_or_none(), i.e. you want to see if a backend is loaded, you don't want to cause the default to be loaded.
I prevented IPython from importing backend_inline where the problem starts (see here) and it seems to cause no difference in Jupyter notebook - so I'm not entirely sure what matplotlib-inline is supposed to be doing. It's quite likely I don't understand what I'm even testing here.
I've been working on the GUI event loop hooks in IPython, and while working on this issue, I realized that importing
backend_inlinewill triggermatplotlib's "auto backend selection". In many systems, this results in selectingQtAggand thus in IPython, this effectively calls%gui qt.The issue is that
'qt'as far as GUI event loop hooks go implies "latest version of Qt", and once a version of Qt is imported in a session, you can't change it. So on a system with e.g.pyside6andPyQt5installed, starting IPython with--matplotlib=qt5will result in an effective%gui qtcall, which will importpyside6, followed by a%gui qt5call, which will refuse to run because it cannot importPyQt5.The culprit is this:
matplotlib-inline/matplotlib_inline/backend_inline.py
Line 213 in fbf0ab8
I believe that should instead call
_get_backend_or_none(), i.e. you want to see if a backend is loaded, you don't want to cause the default to be loaded.I prevented IPython from importing
backend_inlinewhere the problem starts (see here) and it seems to cause no difference in Jupyter notebook - so I'm not entirely sure whatmatplotlib-inlineis supposed to be doing. It's quite likely I don't understand what I'm even testing here.