Skip to content

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

Closed
@shaperilio

Description

@shaperilio

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions