I am trying to plot a simple graph using pyplot, e.g.:
import matplotlib.pyplot as plt
plt.plot([1,2,3],[5,7,4])
plt.show()
but the figure does not appear and I get the following message:
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
I found and tried some advice to re-configure the "backend" mentioned in that warning, like so:
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
but this gives me an error message:
ModuleNotFoundError: No module named 'tkinter'
I assumed that I had to install this module separately, but pip install tkinter
does not work:
Collecting tkinter
Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter
How can I make Matplotlib display the graph?
See also: Why does tkinter (or turtle) seem to be missing or broken? Shouldn't it be part of the standard library? . This question is not a duplicate, because the answers discuss other backends besides the Tkinter one.
Also see _tkinter.TclError: no display name and no $DISPLAY environment variable for issues with attempts to use Matplotlib remotely.