No module named 'Tkinter' - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: No module named 'Tkinter' (/thread-27981.html) Pages:
1
2
|
No module named 'Tkinter' - All_ex_Under - Jun-30-2020 I'm a beginner, and from my first steps, I have a strange problem. No matter what I have done (google it, set a virtual environment, reinstalling the language several times, installing deferent versions of the language) when I'm trying to give the code: from future.moves import Tkinter as tk window = tk.tk() # to rename the title of the window window.title("GUI") # pack is used to show the object in the window label = tk.label(window, text = "Welcome to DataCamp's Tutorial on Tkinter!").pack()It gives me the following error: All that, after I have tried with pip in the CMD to install the module.Though it is included with Python (as I know) I am running a Windows 10 tablet and I have the 3.7.3 version of Python. RE: No module named 'Tkinter' - jdos - Jun-30-2020 (Jun-30-2020, 07:57 AM)All_ex_Under Wrote:from future.moves import Tkinter as tk window = tk.tk() # to rename the title of the window window.title("GUI") # pack is used to show the object in the window label = tk.label(window, text = "Welcome to DataCamp's Tutorial on Tkinter!").pack() Have you tried from future.moves import tkinter as tk window = tk.Tk()as capitalization matters, I tried that with tkinter and works just fine (well it does load the library) for example after you set tkinter you will get an error for your tk.tk() as it should be tk.TK() the same goes for label, it should be Label so it should be from future.moves import tkinter as tk window = tk.Tk() # to rename the title of the window window.title("GUI") # pack is used to show the object in the window label = tk.Label(window, text = "Welcome to DataCamp's Tutorial on Tkinter!").pack() RE: No module named 'Tkinter' - pyzyx3qwerty - Jun-30-2020 @jdos, your solution gives an excellent explanation, but the real problem is that he doesn't have the Tkinter module installed. To do so, just go through this link and proceed with the installation, depending upon your operating system/ RE: No module named 'Tkinter' - All_ex_Under - Jun-30-2020 In the first time, I installed it in D drive, now besides I reinstalled my python in my C drive (during the installation some shadows were telling me that some packages won`t be installed)but IntelliJ keeps looking at D:, it still gives me an error: On the other side, it is still not recognizing the "Tkinter" module :import TKinter Telling me that the module still doesn`t exist. RE: No module named 'Tkinter' - Malt - Jun-30-2020 (Jun-30-2020, 01:42 PM)All_ex_Under Wrote: In the first time, I installed it in D drive, now besides I reinstalled my python in my C drive (during the installation some shadows were telling me that some packages won`t be installed)but IntelliJ keeps looking at D:, it still gives me an error: Did you update your Python path with the latest one? And map your current Python path to the editor as well. Try running PIP command from the latest path RE: No module named 'Tkinter' - Marbelous - Jun-30-2020 You may still have other issues but as jdos mentioned you need to use "tkinter" for python 3. "Tkinter" is for python 2. There is an example of how to detect the python version in this thread: https://stackoverflow.com/questions/17843596/difference-between-tkinter-and-tkinter RE: No module named 'Tkinter' - and2handles - Jun-30-2020 Have u named your py file tkinter.py? If so u should rename it, thats how I was able to solve the problem. RE: No module named 'Tkinter' - snippsat - Jun-30-2020 No need to use future.moves and as posted you most use import tkinter for Python 3.Not import Tkinter (Is for the dead Python 2).you see this clearly on doc to A Simple Hello World Program. RE: No module named 'Tkinter' - jdos - Jun-30-2020 First why don't you install v3.8? Second, if you have problems with the path, uninstall all versions, reboot, install new version. When you start the installer be sure to check the auto path install. After that locate your python (usually C:\Users\user\AppData\Local\Programs\Python\Python38-32\Scripts\) start cmd as administrator, cd to that folder and then run 'pip install tkinter' and all the other modules and libraries that you need. Open IDLE and start coding. And always remember, Capitalization matters. Tkinter is not tkinter for v3. 'label' is not 'Label' and tk.tk() is not tk.Tk(), that is to help you out of trouble. If you need help with the commands check TkDocs. Cheers! RE: No module named 'Tkinter' - All_ex_Under - Jun-30-2020 Thank you all, I m thinking to go with Jdos suggestion, in fact I ve already solved the issue with the path through running my system as administrator.
|