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()
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()
转载于:https://www.cnblogs.com/students/p/8963420.html