This is an issue that has been bugging me for about 5 hours. Until I reached the solution of changing the backend of Matplotlib for good.
Credits: https://stackoverflow.com/a/43015816/1928610
import matplotlib
gui_env = ['TKAgg','GTKAgg','Qt4Agg','WXAgg']
for gui in gui_env:
try:
print "testing", gui
matplotlib.use(gui,warn=False, force=True)
from matplotlib import pyplot as plt
break
except:
continue
print "Using:",matplotlib.get_backend()
Credits: https://stackoverflow.com/a/43015816/1928610