Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
No module named 'Tkinter'
#1
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:
Error:
Traceback (most recent call last): File "D:/Applications/Python 3.7.2/Scripts/Modules-and-Functions-in-Python-Introduction-to-Tkinter-Source-code/sowtest.py", line 1, in <module> from future.moves import Tkinter as tk File "C:\Users\Αλέκος Βαγιώνης\venv\python 3.7\lib\site-packages\future\moves\tkinter\__init__.py", line 27, in <module> from Tkinter import * ModuleNotFoundError: No module named 'Tkinter' Process finished with exit code 1
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.
Reply
#2
(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()
Reply
#3
@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/
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#4
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:
Error:
"C:\Users\Αλέκος Βαγιώνης\venv\python 3.7\Scripts\python.exe" "C:/Users/Αλέκος Βαγιώνης/venv/python 3.7/tesrtk.py" No Python at 'D:\Applications\Python 3.7.2\python.exe' Process finished with exit code 103
On the other side, it is still not recognizing the "Tkinter" module :
import TKinter

Telling me that the module still doesn`t exist.
Reply
#5
(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:
Error:
"C:\Users\Αλέκος Βαγιώνης\venv\python 3.7\Scripts\python.exe" "C:/Users/Αλέκος Βαγιώνης/venv/python 3.7/tesrtk.py" No Python at 'D:\Applications\Python 3.7.2\python.exe' Process finished with exit code 103
On the other side, it is still not recognizing the "Tkinter" module :
import TKinter

Telling me that the module still doesn`t exist.

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
Reply
#6
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/1784...nd-tkinter
"So, brave knights, if you do doubt your courage or your strength, come no further, for death awaits you all with nasty, big, pointy teeth!" - Tim the Enchanter
Reply
#7
Have u named your py file tkinter.py? If so u should rename it, thats how I was able to solve the problem.
Reply
#8
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.
Reply
#9
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!
Reply
#10
Thank you all, Im thinking to go with Jdos suggestion, in fact Ive already solved the issue with the path through running my system as administrator.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  no module named 'docx' when importing docx MaartenRo 1 891 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 23,807 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 2,598 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,460 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,521 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 1,345 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 1,043 Jul-09-2023, 11:24 AM
Last Post: yaoyao22
  Help with pyinstaller "No module named" korenron 9 9,136 Jun-15-2023, 12:20 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 1,017 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  ModuleNotFoundError: No module named 'omsdk.sdkproto' donvito7 4 1,867 Oct-20-2022, 02:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020