import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
当运行上述代码时,报错
ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running
matplotlib的版本号为3.2,使用matplotlib.get_backend()
时返回为'agg'
将后端改为'TkAgg'时出现上述报错
但是使用conda list命令查询安装包时发现其实已经安装了tk