Python Forum

Full Version: Problem with tkinter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
© 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.
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.
tkinter is included by default in the windows python distribution
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
(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
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.
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
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.
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
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.
Pages: 1 2 3