Some users may not want to change the backend for all of their scripts. This page — http://matplotlib.org/faq/usage_faq.html#what-is-a-backend — tells another way:
import matplotlib
matplotlib.use('TkAgg')
You have to do this before importing a subpackage of matplotlib
or a third-party package that depends on matplotlib
.