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

Importing backend_inline triggers selection of QtAgg backend and tie-in of GUI event loop in IPython #25

Open
shaperilio opened this issue May 3, 2023 · 0 comments

Comments

@shaperilio
Copy link

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.

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

1 participant