Skip to content

Interactive matplotlib plot backend freezes when using ipkernel 7.x.x with visual code #1466

@Tatwin845

Description

@Tatwin845

Configuration:
Visual code with Jupyter extension v2025.9.1, ipykernel 7.0.1, python 3.13.8

Issue:
I get stuck when trying to plot something using an interactive window.
There are 2 strange behaviors:

import numpy as np
import matplotlib
from matplotlib import pyplot as plt
%matplotlib tk

plt.figure()
plt.plot(np.arange(10))
plt.show()

print("hello")

=> an empty interactive window opens and freezes, no "hello" printed and the interactive window can be closed using plt.close('all').

import numpy as np
import matplotlib
from matplotlib import pyplot as plt
matplotlib.use('TkAgg')

plt.figure()
plt.plot(np.arange(10))
plt.show()

print("hello")

=> As expected an interactive window opens properly with the expected plot, no "hello" printed until we close the plot window.

import numpy as np
import matplotlib
from matplotlib import pyplot as plt
matplotlib.use('TkAgg')

plt.figure()
plt.plot(np.arange(10))
plt.show(block=False)

print("hello")

=> same results as 1), an empty interactive window opens and freezes, no "hello" printed and the interactive window can be closed using plt.close('all').

After replacing ipykernel 7.0.1 by 6.31.0, the short code in 3) works properly, i.e. interactive plot window which is not blocking the code execution if it is not closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions