0

When I try to import tkinter, this is the message I get:

Traceback (most recent call last):
  File "Num_inc_dec.py", line 1, in <module>
    from Tkinter import *
ImportError: No module named Tkinter

I've searched for my error and have found nothing. I've tried just typing import Tkinter. I'm using python 2.7, but just in case I have also tried using a lower case t.

Additional:

I'm using cygwin to launch my .py files as I'm new to programming, and that was in the tutorial to setting up an environment to work in that I used. I suspect this is part if not the error as I can find nothing online fixing my problem.

Edit: I fixed it. When installing cygwin I had to enable something to get it to work. I searched tkinter and enabled it from the thing that came up.

Ikhoza
  • 11
  • 1
  • 3
  • You have to install this module. – Psytho Jun 06 '16 at 05:29
  • You're using windows (I infer from cygwin)? If so, installing package is the least-easy of the operating systems, but did you try just re-installing Tkinter? This looks vaguely relevant http://www.tkdocs.com/tutorial/install.html#installwin. You also may have had the option when installing cygwin, I don't remember but there are ton of options – en_Knight Jun 06 '16 at 05:30
  • Have you read the following? It was the first result when I googled "python cygwin": https://www.davidbaumgold.com/tutorials/set-up-python-windows/ – Bryan Oakley Jun 06 '16 at 13:42

1 Answers1

0

"The Python Windows Installers include Tcl/Tk as well as Tkinter. These are essentially a one-click install of everything needed." http://tkinter.unpythonic.net/wiki/How_to_install_Tkinter

I would check that you are actually running the correct version of Python. Perhaps try explicitly stating you would like to run 2.7 with

$python2.7
>>> import Tkinter

As

import Tkinter

will return an ImportError in python 3.5. But will execute correctly in 2.7.

Then if the problem has not been solved, just reinstall python 2 with the windows installer. Tk and Tkinter are packaged with the python installer.