python - 我无法安装 Tkinter 或 tkinter。我尝试了所有代码并重新安装了 TCL/TK。但是还是报错
问题描述
我在 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
解决方案
看起来你在 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
推荐阅读
- javascript - Javascript click event doe not work on wordpress
- laravel - Laravel Socialite - 升级 Twitch 范围
- karate - 空手道 DSL:无法读取文件名中包含某些字符的文件
- react-native - 无法安装 expo cli 致命错误:堆限制附近的无效标记压缩分配失败 - JavaScript 堆内存不足
- javascript - 如何在反应中将其他语言的打印命令输出到自定义组件控制台?
- c# - String.Normalize() 的反面:组合字符串?
- matplotlib - 带有 tkinter 和多处理的不确定进度条
- sql - 项目数据和累计远期
- java - 如何在黄瓜步骤中正确使用 Builder 模式
- reactjs - 类型错误:_firebase__WEBPACK_IMPORTED_MODULE_2__.default.child 不是函数