太长不看版
切回ubuntu16原始源,再安装就可以了
问题记录
再tensorflow中使用matplotlib的时候出现问题,图形没有出现,后面发现并不是tensorflow的问题
import matplotlib.pyplot as plt
plt.plot()
plt.show()
报错:
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
搜索之后解决方案是在代码中加入
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
之后又报错
ModuleNotFoundError: No module named ‘tkinter’
之后就一连串曲折的tkinter安装之路,各种pip3, apt报错
根据各种报错信息,终于定位到了问题需要安装python3-tk

在Ubuntu16环境中,使用TensorFlow时遇到matplotlib图形显示问题,经排查发现是缺少tkinter模块。尝试通过pip3和apt安装tkinter失败,错误提示找不到包。最终解决方案是切回Ubuntu16的原始源,成功安装了python3.6的tkinter,从而解决了matplotlib绘图问题。
最低0.47元/天 解锁文章
835

被折叠的 条评论
为什么被折叠?



