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

import matplotlib

import matplotlib.pyplot as plt

fig=plt.figure()

#交互式测试,此时报错

解决办法,在引用后添加下面这一行

matplotlib.use('Agg')

例如

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt fig=plt.figure()
fig=plt.figure()

猜你喜欢

转载自www.cnblogs.com/students/p/8963420.html