这是测试代码:
import numpy as np
from matplotlib import pyplot as plt
x = np.arange(1,11)
y = 2 * x + 5
plt.title("Matplotlib demo")
plt.xlabel("x axis caption")
plt.ylabel("y axis caption")
plt.plot(x,y)
plt.show()
这是报错信息:
raceback (most recent call last):
File "matploitDemo.py", line 6, in
plt.title("Matplotlib demo")
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/pyplot.py", line 1419, in title
return gca().set_title(s, *args, **kwargs)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/pyplot.py", line 969, in gca
return gcf().gca(**kwargs)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/pyplot.py", line 586, in gcf
return figure()
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/pyplot.py", line 533, in figure
**kwargs)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 161, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/backends/_backend_tk.py", line 1046, in new_figure_manager_given_figure
window = Tk.Tk(className="matplotlib")
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/tkinter/__init__.py", line 2023, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
大哥, 您见过几个人能在terminal里画图的.......................matplotlib 只能在notebook里面用
AI Studio环境不是本地,运行没法弹窗啊