参考:
Python下"No module named _tkinter"问题解决过程总结
- plt.show()报错:
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show()
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
- 报错:ModuleNotFoundError: No module named ‘_tkinter’
sudo apt install python3-tk (Ubuntu)
sudo apt install tk-dev (Ubuntu/Debian)
- 报错:No module named ‘_tkinter’
# 重新编译python
cd /usr/local/Python-3.6.8
sudo ./configure --prefix=/usr/local/python/python3 --with-ssl
sudo make test
sudo make install
- 运行成功