You might want to call:

matplotlib.pyplot.switch_backend('Agg') 

so that your server does not try to create (and then destroy) GUI windows that will never be seen.