windows tkinter install python 3.7.4 - python

installed PYTHON 3.7.4 from the python.org website. Working on a windows 10 machine. everywhere it says tkinter should be part of it but it seems like it's not. I need help installing it.

This is the official documentation for the standard library Tkinter created by the folks at Python Software Foundation :
Tkinter
This will definitely help you install, import and get started with Tkinter on your Windows system.
For importing errors while trying to use Tkinter, please note :
The root of the problem is that the Tkinter module is named Tkinter (capital "T") in python 2.x, and tkinter (lowercase "t") in python 3.x.
To make your code work in both Python 2 and 3 you can do something like this:
try:
# for Python2
from Tkinter import *
except ImportError:
# for Python3
from tkinter import *
But since you've already mentioned that you're on Python 3.7.4, this import statement will suffice :
import tkinter as tk

Tkinter is built in with every Python installation.
I don't know if you typed the command wrong, but this is the proper way.
import Tkinter as tk
Note: There is a Capital T at the beginning of Tkinter.
In Python 3 for you,
import tkinter as tk
Note: You might accidentally deleted it in the folder of python so you could just download python again.

Below from https://pypi.org/project/PySimpleGUI/:
Python 3.7
If you must run 3.7, try 3.7.2. It does work with PySimpleGUI with no known issues.
PySimpleGUI with Python 3.7.3 and 3.7.4+. tkinter is having issues with all the newer releases. Things like Table colors stopped working entirely. It's unclear if there's been a change that makes the tkinter API no longer working which means they are not backwards compatible. That would be a real shame. If so, more work needs to be done in PySimpleGUI

Can you import tkinter by import tkinter?

Related

ModuleNotFoundError: No module named 'tkinter' after

I have been recently attempting to try out some minor game development with Python 3.9 and have been running into some problems. For some reason, Python does not recognize that I have tkinter installed.
From what I have seen online, a big fix is to make sure the path variables are set up correctly. I have already added it to my env variables but that has not seemed to fix anything.
I also know I have it installed, as I see it here in my Python site-packages folder.
At this point, I am stumped. I do have the import as tkinter as well and not Tkinter.
The only thing I can think of now is totally uninstalling Python but I would prefer not to do that if there are any other options.
Here is the code:
import math
import random
import pygame
import tkinter as tk
from tkinter import messagebox
class cube(object):
rows = 20
w = 500
I am using Windows 10 and VSCode as well.
Anything helps and thanks!
Seems I somehow screwed up my Python installation. Completely removing it from my system and reinstalling seemed to fix all of my issues.

Python turtle: problems with tkinter

So I wanted to use the python package turtle, which uses the underlying package tkinter.
With this code:
import turtle
python raised an error which said, that the package tkinter was not found.
So I edited the turtle.py file and changed the
from tkinter import xyz
to
from tk import xyz
and at least the error was gone, but another appeared.
It is now saying
ImportError: cannot import name 'simpledialog' from 'tk' (C:\PYTHON\lib\site-packages\tk\__init__.py)
I've updated pip and reinstalled both packages.
I'm using python 3.9.1 on Windows.
Try using:
from tkinter.simpledialog import askstring
Or whichever type of simpledialog you want to make
Feel free to ask question in case of confusion.

No module named Tkinter error

I have been using http://python.codnex.net/index.php. I have tried to use Tkinter but it shows ImportError: No module named Tkinter on line 1
I have tried many things including:
import Tkinter
import tkinter
from tkinter import *
If you find something please let me know.
According to this question & answer in Quora you can't use tkinter with online interpreters. Though apparently you can run linux along chromeOS if you have non-school version.
I might be wrong, but I believe it's because tkinter is a GUI module, which can't be ran from a webbrowser.
Have you tried importing it in a local python instance?
it wont work on web browser ,Run a local python instance and import tkinter after installing tkinter by using command prompt using the command pip install python-tk

Pyinstaller, .py version works, .exe "No module named Tkinter"?

I don't understand how this happened. myscript.py works, Tkinter is installed. However once I converted it to .exe using pyinstaller, I ran myscript.exe, I got a message in command prompt saying "No module named Tkinter".
How can I fix this?
I've already tried to convert it several times, tried using --noupx, and also tried reinstalling pyinstaller. Thanks
PyInstaller - Hidden Imports
Try using the --hiddenimport flag. Do --hiddenimport=Tkinter, or replace the Tkinter with whatever module you need. The issue seems reoccurring throughout the PyInstaller community. Here is one article.
Name Space
Tkinter has changed its namespaces from Python 2 to Python 3. It's now named tkinter in Python 3 and Tkinter in Python 2. This is the code I like to use so it's cross-version.
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
Then you can reference Tkinter as tk. Or if you do from Tkinter import * you can just use everything without a namespace. See the list here for more of the name changes between version.

Using Tkinter on OSX Mountain Lion 8.2

I'm working on learning to make GUIs with Tkinter for Python programs and I have run into a bunch of problems:
Attempting to run from Tkinter import filedialog I get ImportError: cannot import name filedialog. Elsewhere I have seen it called with the lowercase tkinter (which I think is for Python 3 only) but it does not recognize that as existing ImportError: No module named tkinter. Yet running from Tkinter import * works and I'm able to create the sample hello world from the tutorial.
My only guess is that it is attempting to use an obsolete version of Tkinter that shipped with OSX. Yet considering how new Mountain Lion is, I have to wonder how obsolete it would really be. My assumption is that upon installing Python 2.7 myself, if I run from IDLE, it should work, but instead I get exactly the same thing above from the IDLE shell.
So after that I tried sudo pip install tkinter and sudo pip install Tkinter from the Unix terminal, but I get back No distributions at all found for update
So I start looking into documentation on Tkinter itself, and I come across Tcl/Tk instructions for Mac OS X which states:
Important: If you are using Mac OS X 10.8, 10.7 or 10.6, use IDLE or tkinter from a 64-bit/32-bit Python installer only with ActiveTcl 8.5 installed. If you cannot install ActiveTcl 8.5, use a 32-bit-only installer instead.
So I find my OS in the table they provide and see that they recommend ActiveTcl8.5.11, but unfortunately, the download link is broken.
So I'm completely at a loss here. Any help would be appreciated.
If you want to implement a File Dialog, have a look at tkFileDialog. It is a seperate module & not part of Tkinter module.
You can use it by directly importing it:
import tkFileDialog

Categories

Resources