Skip to content

Enabling %matplotlib qt in IPython shell slows it down significantly #14581

@AmerM137

Description

@AmerM137

To reproduce:
Fire up a terminal, activate conda environment and enter ipython. This is a normal ipython terminal (not jupyter console or jupyter qtconsole).

At first, the shell is responsive even after many imports and trying out different data manipulation operations. As soon as %matplotlib qtis enabled, the shell slows down to a crawl, both input and time to show output. It feels as if there is a large roundtrip that is being taken by the input.

I understand that the matplotlib event loop needs to hook into ipython's loop or something along those lines, but it's very slow and the input delay is significant.

Other backends/frontends:
It looks like the issue does not exist with jupyter-qtconsole.
Update 11/17/24: Performance degradation does not happen with c.InteractiveShellApp.matplotlib = "tkagg"
Looks like something is causing the qt backend to degrade performance.

OS: Windows 11 24H2 Build 26100.2314
Terminal: Windows Terminal 1.21.2911.0 (native, no WSL)

Relevant packages:
python            |     3.12.7   |       hce54a09_0_cpython |  conda-forge
ipython           | 8.29.0   | pyh7428d3b_0 | conda-forge
ipython_genutils | 0.2.0  |  pyhd8ed1ab_1 |  conda-forge
prompt-toolkit |   3.0.48 |    pyha770c72_0 |        conda-forge noarch
pygments        |  2.18.0 |    pyhd8ed1ab_0   |      conda-forge noarch
matplotlib        | 3.9.2   | py312h2e8e312_2 | conda-forge
matplotlib-base  |  3.9.2   | py312h90004f6_2 |  conda-forge
matplotlib-inline | 0.1.7    | pyhd8ed1ab_0   |  conda-forge
jupyter                  | 1.1.1   | pyhd8ed1ab_0 | conda-forge
jupyter-lsp              | 2.2.5  |  pyhd8ed1ab_0 | conda-forge
jupyter_client           | 7.4.9  |  pyhd8ed1ab_0 | conda-forge
jupyter_console       |    6.6.3 |   pyhd8ed1ab_0 |  conda-forge
jupyter_core            |  5.7.2   | pyh5737063_1 |  conda-forge
jupyter_events        |    0.10.0 |  pyhd8ed1ab_0  | conda-forge
jupyter_server        |    2.14.2  | pyhd8ed1ab_0 | conda-forge
jupyter_server_terminals  0.5.3  |  pyhd8ed1ab_0 | conda-forge
jupyterlab              |  4.3.0 | pyhd8ed1ab_0 | conda-forge
jupyterlab_pygments  |     0.3.0  |  pyhd8ed1ab_1 | conda-forge
jupyterlab_server       |  2.27.3  | pyhd8ed1ab_0 | conda-forge
jupyterlab_widgets    |    3.0.13  | pyhd8ed1ab_0 | conda-forge

I am happy to run any tests on my end to narrow down the issue. I have a fairly beefy workstation and this is really the only situation where I encounter lag with my inputs/outputs in the terminal.

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