我无法安装 Tkinter 或 tkinter。我尝试了所有代码并重新安装了 TCL/TK。但是还是报错

Mah*_*han 0 python tkinter python-3.x

我在 stackover 和许多其他网站上尝试了所有解决方案。但它仍然给出同样的错误。我什至无法安装它。

C:\Users\***\Google Drive\Python>pip install tkinter
Collecting tkinter
  Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter

C:\Users\***\Google Drive\Python>pip install Tkinter
Collecting Tkinter
  Could not find a version that satisfies the requirement Tkinter (from versions: )
No matching distribution found for Tkinter

C:\Users\***\Google Drive\Python>pip install Tk
Collecting Tk
  Could not find a version that satisfies the requirement Tk (from versions: )
No matching distribution found for Tk

C:\Users\***\Google Drive\Python>pip install tk
Collecting tk
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'Varolan bir ba?lant? uzaktaki bir ana bilgisayar taraf?ndan zorla kapat?ld?', None, 10054, None))': /simple/tk/
  Could not find a version that satisfies the requirement tk (from versions: )
No matching distribution found for tk

C:\Users\***\Google Drive\Python>pip install python3-tk
Collecting python3-tk
  Could not find a version that satisfies the requirement python3-tk (from versions: )
No matching distribution found for python3-tk
Run Code Online (Sandbox Code Playgroud)

Sim*_*mon 5

看起来你在 Windows 上,在这种情况下你已经有了 tkinter(如果你运行 2.7 或更高版本)。看来你使用 Python 3 所以运行import tkinter. 查看文档

如果您使用的是 Linux/Mac/类似变体,那么您需要运行sudo apt-get install python3-tk. 它不是一个pip包,不能以这种方式安装。

如果该python -m tkinter命令在 Windows 上失败,则您的安装已损坏,或者如果在 Linux/Mac/Similar 上,则上述命令应该可以工作。


在 Windows 上,有两件事可能会出错:

  • 你的安装坏了
  • 你忘了检查 tkinter 的选项

如果您的安装已损坏,则重新安装您应该可以工作,但更有可能是您tck/tk and IDLE在安装时忘记检查该选项。要检查或安装,请重新运行安装程序并按modify。您应该会看到如下所示的框。确保然后tck/tk and IDLE确实有一个勾号:

在此处输入图片说明

并按 Next

  • 我在 Windows 上使用 Python3.6.3。实际上我正在尝试使用 matplotlib。但是当我尝试导入时,它没有给我任何模块名称 tkinter。`Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 位 (AMD64)] on win32 输入“help”、“copyright”、“credits”或“license” “ 想要查询更多的信息。>>>` (2认同)