我只想通过在 VSCode 中运行 Python 进行绘图,但结果却失败了。我无法将后端从 agg 切换到 Qt5Agg。但是,我可以轻松地在 VSCode 的终端中执行此操作...
VSCode集成终端的问题如下图,我尝试了各种解决方案都失败了..:
(base) user@user:~/test$ export MPLBACKEND=Qt5Agg
(base) user@user:~/test$ python
Python 3.8.3 (default, Jul 2 2020, 16:21:59)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> print("Using:",matplotlib.get_backend())
Using: Qt5Agg
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3], [10, 20, 30])
[<matplotlib.lines.Line2D object at 0x7fe26b403d00>]
>>> plt.show()
>>> print("Using:",matplotlib.get_backend())
Using: agg
>>> plt.switch_backend('Qt5Agg')
Traceback (most recent call last):
File "<stdin>", line 1, in …Run Code Online (Sandbox Code Playgroud)