-
-
Notifications
You must be signed in to change notification settings - Fork 35
Description
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:
| backend = get_backend() |
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.