matplotlib报错_tkinter.TclError: no display name and no $DISPLAY environment variable

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()

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324963685&siteId=291194637