1, 安装 tk-dev 和 python3-tk
sudo apt-get install tk-dev
sudo apt install python3-tk
2,修改 matplotlibrc 文件
sudo geidt ~/.../lib/python3.6/site-packages/matplotlib/mpl-data/matplotlibrc
搜索:#backend : Agg
替换为: backend : TkAgg
3,如果需要,重新安装 matplotlib:
pip uninstall -y matplotlib
pip --no-cache-dir install -U matplotlib
来源:https://blog.csdn.net/Merlin_Bloom/article/details/100124596