import matplotlib.pyplot as plt 改为: import matplotlib matplotlib.use('AGG') import matplotlib.pyplot as plt