matplotlib error - no module named tkinter

problem

import matplotlib.pyplot as plt
ImportError: No module named 'tkinter'

solution 1

import matplotlib
matplotlib.use('agg')  # agg is a non-GUI backend, so plt.show() will not have any effect. But you can still do plt.savefig(filename) and look at the file for quick debugging.
import matplotlib.pyplot as plt

solution 2

yum install tkinter # some thing else and so on