2

I am able to generate *.dat file. Post that when I attempt to plot the graph using mprof, it's throwing exception:

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

I am running this command on ubuntu hosted VM.

vikas
  • 901
  • 3
  • 10
  • 13
  • 1
    Looks like this is a problem with backend. Try without the X backend, e.g. add `import matplotlib; matplotlib.use('Agg')` to the top of the file and run. Also, replace `plt.show()` with`plt.savefig('out.png')` – Ed Smith Oct 07 '15 at 08:23

1 Answers1

1

That seems a problem with matplotlib. You can try changing the backend to Agg in the matplotlibrc file (so that it saves a file instead of displaying the result):

http://matplotlib.org/users/customizing.html
Fabian Pedregosa
  • 6,329
  • 1
  • 22
  • 20