Python Forum
Problem with tkinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with tkinter
#1
© 2017 Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>pip install tkinter
Collecting tkinter
Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter

C:\WINDOWS\system32>
Hi all ! Is there somebody that can help me. The file worked well with linux, and I should like it does the same with windows. Windows does not find the module tkinter. As you see above, I cannot install tkinter. I use Pycharm, my interpreter is python 3.6.
Reply
#2
I think tkinter is included in python, you don't need to install it. Try the statement import tkinter in the python interpreter. If there is no error message, it means that you already have tkinter.
Reply
#3
tkinter is included by default in the windows python distribution
Reply
#4
I found tkinter in C:\Program Files\Python36\Lib\tkinter................and I tried to import it. I got this message:
The project at C:\Program Files\Python36\Lib\tkinter uses a non-standard layout and cannot be attached to this project. Would you like to open it in a new window? ...y/n ?
What do I reply ? yes or no ? Thanks
Reply
#5
(Feb-14-2018, 09:03 AM)sylas Wrote: I tried to import it.
how do you try to import it?

try to run this minimal application
import tkinter as tk

class Application(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.pack()
        self.create_widgets()

    def create_widgets(self):
        self.hi_there = tk.Button(self)
        self.hi_there["text"] = "Hello World\n(click me)"
        self.hi_there["command"] = self.say_hi
        self.hi_there.pack(side="top")

        self.quit = tk.Button(self, text="QUIT", fg="red",
                              command=root.destroy)
        self.quit.pack(side="bottom")

    def say_hi(self):
        print("hi there, everyone!")

root = tk.Tk()
app = Application(master=root)
app.mainloop()
https://docs.python.org/3/library/tkinter.html#a-simple-hello-world-program
Reply
#6
run python3 from command line and see if you can import tkinter.

Your python may be defaulting to python 2.7
in 2.7 it's import Tkinter with capital 'T'
You might have messed up your version by running pip.
Also, I believe there are still some versions of python that
don't automatically install it.
Reply
#7
OP clearly has python 3.6 with tkinter, based on path C:\Program Files\Python36\Lib\tkinter
based on error The project at C:\Program Files\Python36\Lib\tkinter uses a non-standard layout and cannot be attached to this project I think when OP says he is trying to import tkinter they are actually trying to include tkinter folder to PyCharm project, but that is just wild guess
Reply
#8
I tried Buran's file. Always my PC cannot find the module tkinter. All my projects come from my 32bits old PC. I put the project from the USB key into my 64bits PC.First I create a new Project with a name about the same as my old project. Then I import my ancient project with just : File>Open>OK. All files are there,ready to go, and all of them work well, except those with tkinter and pygame....Something I don't like: when I choose the interpreter I have about 10 different python3.6, all of them with the suffix venv. As i know nothing about vitual environment it is not pleasant to choose a venv, but I cannot do otherwise.
Reply
#9
Don't try it from within PyCharm. Just open Notepad, paste my code, save the file as hello.py, then open command prompt, change CWD to folder where hello.py is and type in cmd prompt python hello.py
Reply
#10
Thanks Buran. I opened Notepad, I saved "hello.py", after that I am lost. "Open command prompt", do you mean terminal ? "Change CWD to folder", there I don't know "CWD". Explain please.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python3 tkinter radiobutton problem Nick_tkinter 14 6,007 Feb-15-2021, 11:01 PM
Last Post: Nick_tkinter
  tkinter python button position problem Nick_tkinter 3 3,557 Jan-31-2021, 05:15 AM
Last Post: deanhystad
  [Tkinter] ClockIn/Out tkinter problem Maryan 2 2,201 Oct-12-2020, 03:42 AM
Last Post: joe_momma
  tkinter| listbox.insert problem Maryan 3 3,505 Sep-29-2020, 05:34 PM
Last Post: Yoriz
  Tkinter problem DPaul 6 4,129 May-28-2020, 03:40 PM
Last Post: DPaul
  [Tkinter] Tkinter - I have problem after import varaible or function from aGUI to script johnjh 2 2,578 Apr-17-2020, 08:12 PM
Last Post: johnjh
  [Tkinter] Problem with tkinter when creating .exe file Jan_97 2 4,594 Feb-27-2020, 05:17 PM
Last Post: Jan_97
  [Tkinter] Tkinter problem catlessness 1 2,047 Jan-15-2020, 05:17 AM
Last Post: Larz60+
  Problem with Submit button Tkinter Reldaing 2 3,659 Jan-05-2020, 01:58 AM
Last Post: balenaucigasa
  tkinter GUI, problem running seperate files fishglue 17 6,353 Oct-15-2019, 02:56 PM
Last Post: Denni

Forum Jump:

User Panel Messages

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