不会绘图



我可以生成*.dat文件。当我尝试使用mprof绘制图形时,它会抛出异常:

vikas@server:~/memory_profiler-0.36$ ./mprof plot --output=plot.png
Using last profile data.
Traceback (most recent call last):
  File "./mprof", line 494, in <module>
    actions[get_action()]()
  File "./mprof", line 454, in plot_action
    pl.figure(figsize=(14, 6), dpi=90)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in figure
    **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 79, in new_figure_manager
    return new_figure_manager_given_figure(num, figure)
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 87, in new_figure_manager_given_figure
    window = Tk.Tk()
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

我在ubuntu主机上运行这个命令

这似乎是matplotlib的一个问题。您可以尝试在matplotlibrc文件中将后端更改为Agg(这样它将保存文件而不是显示结果):

http://matplotlib.org/users/customizing.html

最新更新