0

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
Xantium
  • 11,201
  • 10
  • 62
  • 89
Mahir Yıldızhan
  • 53
  • 1
  • 2
  • 11

2 Answers2

5

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:

enter image description here

And press Next

Xantium
  • 11,201
  • 10
  • 62
  • 89
  • 2
    I am using Python3.6.3 on Windows. Actualy I am trying to use matplotlib. But when I try to import it gives me no module name tkinter. `Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>` – Mahir Yıldızhan Apr 25 '18 at 12:35
  • 1
    `C:\Users\asus>python -m tkinter C:\Python36\python.exe: No module named tkinter` – Mahir Yıldızhan Apr 25 '18 at 12:38
  • 1
    @MahirYıldızhan I think I have found the problem you have. Could you please take a look at my edited answer – Xantium Apr 25 '18 at 15:04
  • Just run the installer again , press the "Modify" button. Any existing modules will not get removed. Close your IDE first though. –  Mar 08 '20 at 10:31
  • 1
    Thanks. `sudo apt-get install python3-tk` solved my `no module named PySimpleGUI` problem on Linux Mint. The fact that the real problem, is hidden, makes life a little confusing. – Hugh Barnard Jun 11 '21 at 06:58
  • Thanks. And @HughBarnard I had the same problem, until I found this thread :-) – Gaurav Jul 17 '21 at 17:07
0

So, as a user on Windows 10, I've mainly stuck to using just good ol' IDLE ... I must've gotten bored this weekend and for some crazy reason, decided to download and install Visual Studio. Obviously, being unfamiliar with it, I ran into some difficulties and confusion - one of them being VS insisting on using IT'S python environment rather than the more updated and latest one I already have installed.

This would be fine, especially since I could add only the packages that I needed to import, however... Visual Studio runs into the same issue described here. No form or fashion of attempting to install tkinter works ... python3-tk or otherwise.

I HAVE, however, worked around the issue in my particular case ... by adding the IDLE installation I already had to the Visual Studio Python environments. Apparently this only worked because IDLE Python installs tkinter as part of it's standard library.

I'm still curious and would like to know what needs to be done for non - IDLE installations, though... I didn't realize how big of a hassle this was before now. The most promising answer I could find leads to the Tcl developers:

https://www.activestate.com/products/tcl/

It appears as though it may require manual installation.