I can't install Tkinter or tkinter. I tried every code and reinstall TCL/TK too. But still got an error

萝らか妹 提交于 2021-02-08 10:23:15

问题


I try every solution on stackover and many other sites. But it's still giving same faults. I even couldn't install it.

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

回答1:


It looks like you are on Windows, in which case you have tkinter already (if you run 2.7 or above). It seems you use Python 3 so run import tkinter. See the documentation

If you are on Linux/Mac/similar variant then you need to run sudo apt-get install python3-tk. It is not a pip package and cannot be installed in this way.

If the python -m tkinter command fails on Windows then your installation is broken, or if on Linux/Mac/Similar then the command above should work.


On Windows there are two things that could have gone wrong:

  • Your installation is broken
  • You forgot to check option for tkinter

If your installation is broken then reinstalling your should work, but more likely you forgot to check the tck/tk and IDLE option when installing. To check or to install re-run your installer and press modify. You should see a box like the following. Ensure then the tck/tk and IDLE does have a tick on it:

And press Next



来源:https://stackoverflow.com/questions/50011989/i-cant-install-tkinter-or-tkinter-i-tried-every-code-and-reinstall-tcl-tk-too

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!