Thanasis Mattas
Thanasis Mattas

Reputation: 514

How to set matplotlib backend at vscode

Ubuntu 19.10, VScode 1.42.0, python 3.7.6, anaconda 4.8.2, matplotlib 3.1.3

It seems that plt.show() doesn't work, because the current matplotlib backend is agg. Running from the terminal, I can use Qt4Agg, but from the integrated terminal inside VScode I cannot change from agg.

Tried the following:

  1. add backend: Qt4Agg at matplotlibrc
  2. __import__("matplotlib").use("Qt4Agg")
    __import__("matplotlib").use("Qt4Agg", warn=False, force=True)
    ImportError: Cannot load backend 'Qt4Agg' which requires the 'qt4' interactive framework, as 'headless' is currently running
  3. plt.switch_backend('Qt4Agg')
    same ImportError
  4. export MPLBACKEND=Qt4Agg before running the command

But, nothing worked. Any suggestions?
Thank you!

Upvotes: 4

Views: 3707

Answers (1)

Tengyu Liu
Tengyu Liu

Reputation: 1253

Not sure if this is still relevant, but it looks like your integrated terminal is running in headless mode. Changing terminal.integrated.inheritEnv to true in settings should fix it.

Upvotes: 1

Related Questions