没有模块名\tkinter安装时出错

2024-04-25 06:05:03 发布

您现在位置:Python中文网/ 问答频道 /正文

尝试通过命令行运行使用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 install 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)。是不是PythonTK是3.6.6版,我的Python3.6.4版?你知道吗

我还有别的方法可以试试吗?你知道吗


Tags: theno命令行import程序formatplotlibis