当尝试通过命令行运行使用matplotlib的python 3程序时,出现以下错误:
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
仅输入以下内容也会发生同样的情况
>>>import tkinter
建议的修复程序(如安装python3-tk,python3.5-tk或python3.6-tk)不起作用,结果为:
python3.6-tk is already the newest version (3.6.6-1+xenial1).
并使用matplotlib.use('agg')无效,因为我需要输出数字:
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
使用pip安装tkinter,python-tk或python3-tk,结果是:
Could not find a version that satisfies the requirement python3-tk (from versions: )
No matching distribution found for python3-tk
我也尝试更新并重新安装python3,但似乎没有任何效果(版本3.6.4)。可能是python-tk是版本3.6.6和我的python 3.6.4吗?
还有其他可以尝试的方法吗?