2

我能够生成 *.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 托管的 VM 上运行此命令。

4

1 回答 1

1

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

http://matplotlib.org/users/customizing.html
于 2015-10-08T09:20:32.323 回答