How to display Image in Ubuntu 16.04 terminal python 2.7 using matplotlib

I am Ubuntu 16.04 terminal, python 2.7 ,matplotlib.

I need to run python script “” ,which should display image

I check my backend using

>>>import matplotlib

I put


because otherwise it was giving me an error

File "/usr/lib/python2.7/lib-tk/", line 1818, in __init__ = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

I also put


but it doesn’t work

please let me know how can I see the image on my ubuntu terminal using


Matplotlib does not have a backend that produces images in a terminal. You need to have a windowing system available if you want to display plots interactively.

The Agg backend is not for display, but for saving to a file directly.

Additionally, Python 2 is end-of-life, so you really should stop using it.