Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib Plot Not Responding in VSCode Debug Mode

I'm encountering an issue when trying to plot a simple graph using Matplotlib in Python while in debug mode in VSCode. The plot works perfectly in normal execution mode, but when I set a breakpoint and run the code in debug mode, the plot window becomes unresponsive.

Example Code:

import matplotlib.pyplot as plt

# Sample data
x = [1, 2, 3, 4, 5]
y = [10, 20, 25, 30, 40]

# Plotting the data
plt.plot(x, y)
plt.title('Sample Plot')
plt.xlabel('x-axis')
plt.ylabel('y-axis')

# Show plot
plt.show()

In normal execution mode, the plot window appears and is responsive. In debug mode with a breakpoint, the plot window appears but becomes unresponsive and eventually throws a "not responding" error.

debug mode error not response

I tried using different Matplotlib backends, but none of them resolved the issue. I expect to be able to plot graphs using Matplotlib in debug mode vscode without the plot window becoming unresponsive.

like image 940
sajad Avatar asked Sep 01 '26 16:09

sajad


2 Answers

I also had this issue. I got it working again by running Python 3.11.9 instead of 3.12.*, and I also had to switch to matplotlib 3.8.3 instead of 3.9.*. Has been driving me crazy for a couple weeks. So, try setting up a virtual environment in VSCode with matplotlib 3.8.3 and switching your interpreter to 3.11.9 in that environment.

like image 134
Matplotlibsadness Avatar answered Sep 04 '26 08:09

Matplotlibsadness


As of today, I was able to display my plot while running in the debugger when I called plt.show() on the debug console with a breakpoint in my plotting code.

My versions of stuff:

  • Python 3.12.4
  • Matplotlib 3.10.0
  • VS Code 1.97.1
  • Python VS Code extension 2025.0.0
like image 37
als0052 Avatar answered Sep 04 '26 07:09

als0052



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!