Tkinter not found

I am running a 32-bit version of Windows 7. I installed Python 3.2.2 and selected each module to install (including Tcl / Tk). On my computer, I can run the script by double-clicking the .py file and it will find my Tkinter import is just fine. If I run it from the command line, it says ImportError: No module named 'Tkinter' . I passed this script to an employee who also set the same path, and she cannot run the script at all even with a double click. Same tkinter problem. Our PATHs are identical with C: \ Python33, which is the first element, and tkinter shows in the lib folder. I'm running out of ideas. What's happening? Why is Tkinter so sophisticated with existing ones?

Update: Tcl / Tk does not seem to include Tkinter. The reason this worked for me was because I installed a special Python package through our company’s download system, which included it. This version has been associated with .py extensions. However, on the command line, my updated Python (with Tcl / Tk but without Tkinter) was the selection python selected by my PATH variable. My colleague did not have this special package, so it did not work for her. I thought it was my Python 3.3 that ran the script, but that was not why it seemed to work for me. However, if anyone else encounters this problem, check sys.executable and sys.version as shown below to find out what happens!

+4
source share
1 answer

You can have both Python 2.x and Python 3.x. The py extension is associated with the Python 2.x interpreter. And your python script is designed to work with Python 2.x.

In Python 3, the Tkinter module was renamed to Tkinter (lowercase).


Make the script as follows, then run it by clicking on it and running it in the command. You can get different results:

 import sys print(sys.version) input() 
+7
source

All Articles