import matplotlib import matplotlib.pyplot as plt fig=plt.figure()
#Interactive test, an error is reported at this time
The solution is to add the following line after the reference
matplotlib.use('Agg')
E.g
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt fig=plt.figure()
fig=plt.figure()