Python Forum
tkinter install broken?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter install broken?
#1
I cannot use tkinter on my Windows install. Even the most basic example fails in the same way:

>>> from tkinter import *
>>> Window = Tk()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python\Python312\Lib\tkinter\__init__.py", line 2346, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: unknown color name "rgb:33/33/33"
I've tried uninstalling/reinstall python, using tk from pip (I know I shouldn't though), removing python from my cygwin environment, running from a venv - same error every time. No idea what could be causing this. Any suggestions?
Reply
#2
what is your OS?
Which version of python are you running?
How did you install tkinter?

tkinter is packaged with most (but not all) python versions and does not require further installation.
kwolfe81 likes this post
Reply
#3
(Jul-25-2024, 09:34 AM)Larz60+ Wrote: what is your OS?
Which version of python are you running?
How did you install tkinter?

tkinter is packaged with most (but not all) python versions and does not require further installation.

Windows 10, I've tried python 3.12.4 and 3.11.9, uninstalling & deleting between versions. I'm installing python and tkinter using the standard windows python GUI installer, ensuring the "tcl/tk and IDE" checkbox is checked during optional features selection.
Reply
#4
I don't use MS windows much, but I use several versions of python (including 3.12.4) and tkinter is installed with the package.

My installs are all from pyenv (which I'd recommend using see this)
I expect that the python.org version for windows includes tkinter.

try running python -m tkinter from the command line, ( doc here )
if everything was installed properly, a simple tkinter window should appear.
kwolfe81 likes this post
Reply
#5
(Jul-26-2024, 12:59 AM)Larz60+ Wrote: I don't use MS windows much, but I use several versions of python (including 3.12.4) and tkinter is installed with the package.

My installs are all from pyenv (which I'd recommend using see this)
I expect that the python.org version for windows includes tkinter.

try running python -m tkinter from the command line, ( doc here )
if everything was installed properly, a simple tkinter window should appear.

Thanks for the support. Same bug:

Microsoft Windows [Version 10.0.19045.4353]
(c) Microsoft Corporation. All rights reserved.

C:\Users\kevin>python -m tkinter
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python\Python312\Lib\tkinter\__main__.py", line 7, in <module>
    main()
  File "C:\Python\Python312\Lib\tkinter\__init__.py", line 4655, in _test
    root = Tk()
           ^^^^
  File "C:\Python\Python312\Lib\tkinter\__init__.py", line 2346, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: unknown color name "rgb:33/33/33"

C:\Users\kevin>
Reply
#6
This is somehow related to my Windows user profile. I was able to create a new user in Windows and tkinter works perfectly fine on that account. *shrug*
Reply
#7
Ok, I'm getting somewhere now. It's gotta be a weird cygwin interaction. The following gets it to work:

set "HOME="
set "HOMEDRIVE="
set "HOMEPATH="
set "USERPROFILE="
Reply
#8
Further down the hole. I have a .Xdefaults file in my user home directory. Removing this file solves the issue. Now to figure out what in that file is the problem.
Reply
#9
Narrowed it down to these two lines:

*background: rgb:33/33/33
*foreground: rgb:ff/ff/ff

*Sigh* At least it's fixed.
Gribouillis likes this post
Reply
#10
kwolfe81 Wrote:*Sigh* At least it's fixed.
Glad to hear it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to install numpy and matplotlib to Tkinter elwolv 4 5,594 Dec-02-2017, 06:17 PM
Last Post: Barrowman

Forum Jump:

User Panel Messages

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