Skip to content

Add a way to disable matplotlib interactive mode #704

@IvanCobotic

Description

@IvanCobotic

Environment data

  • VS Code version: 1.59.1
  • Extension version (available under the Extensions sidebar): v2021.8.1159798656
  • OS and version: Linux x64 5.4.0-81-generic snap Ubuntu 18
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.6.9 64 bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): No virtual environment / N/A
  • Relevant/affected Python packages and their versions: matplotlib 3.3.4
  • Relevant/affected Python-related VS Code extensions and their versions: -
  • Value of the python.languageServer setting: Default

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

If I run the following script by pressing run (f5), it should work as normal. The behavior when debugging should be the same regardless of what breakpoints / stepping and execution method is used. I run the code as a normal python file,
#test_plot.py

import matplotlib.pyplot as plt
plt.plot(range(10))
plt.show()

Actual behaviour

If i set a breakpoint on any of the lines above, the debugger stops on the breakpoint and the following message is printed in the integrated terminal
"Backend Qt5Agg is interactive backend. Turning interactive mode on."

If I continue the execution (with f5) the execution will not pause on the plt.show() as expected, the plot simply flashes by as a black window and the program exits.

I can verify in the debug console with
plt.isinteractive()
->True

I did however not enable interactive mode anywhere in the code.

Also, if i run (in the debug console)
plt.ioff()
This returns None, as expected, but when continuing execution with f5 the execution still will not display / pause on the plt.show() command

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. see snippet above, just the 3 lines are needed to reproduce.

my launch.json is the default file,
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions