Repository navigation
Tkinter not installed correctly on Windows 3.15.0b2 #150836
Description
Bug report
Bug description:
3.15.0b1 was fine. 3.15.0b2 will not start tk/tcl. Difference must be incomplete upgrade to tk 9.0.
If I run the REPL with either the Start icon or py in a console, import tkinter works but a subsequent t = tkinter.Text() fails with
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
t = tkinter.Text()
File "C:\Programs\Python315\Lib\tkinter\__init__.py", line 3857, in __init__
Widget.__init__(self, master, 'text', cnf, kw)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Programs\Python315\Lib\tkinter\__init__.py", line 2853, in __init__
self._setup(master, cnf)
~~~~~~~~~~~^^^^^^^^^^^^^
File "C:\Programs\Python315\Lib\tkinter\__init__.py", line 2818, in _setup
master = _get_default_root()
File "C:\Programs\Python315\Lib\tkinter\__init__.py", line 330, in _get_default_root
root = Tk()
File "C:\Programs\Python315\Lib\tkinter\__init__.py", line 2535, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: Can't find a usable tk.tcl in the following directories:
//zipfs:/app/tk_library //zipfs:/lib/tk/tk_library //zipfs:/lib/tk //zipfs:/lib/tcl/tcl_library/tk9.0 //zipfs:/lib/tcl/tk9.0 C:/Programs/lib/tk9.0 C:/Programs/lib/tk9.0 C:/lib/tk9.0 C:/Programs/libraryThis probably means that tk wasn't installed properly.
The IDLE icon in the start menu does not work. If I pin it to taskbar and click, the blue circle starts and quickly stops. The one for older versions start, quickly stop, and quickly restart until IDLE runs. In a console, py -m idlelib fails at the same _tkinter.create(...) call with the same message.
I have seen a similar message before and I believe the list of directories is obsolete. In a local build, I believe the tcl/tk file needs to be in PCbuild/. My 3.16 build works fine. Installations used to have DLLs/tcl86t.dll and tk86t.dll. 3.15.0b2 has tcl9tk90.dll and tcl90.dll (no t suffix). Is _tkinter.dll looking for those names?
CPython versions tested on:
3.15
Operating systems tested on:
Windows
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
terryjreedy commentedon Jun 3, 2026
import turtlealso works.turtle.Screen()(with the ()s) fails.jjhelmus commentedon Jun 3, 2026
I was able to get Tkinter working with an install of 3.15.0b2 on Windows by adjusting the files in the tcl directory.
Specifically in the tcl directory I:
libtcl9.0.3.zipandlibtk9.0.3.zip.The root issue seems to be that the tcl-tk binary release for 9.0.3.0 uses TclVFS for the tcl and tk libraries which is causing an issue, although the tcl library seems to load fine from the zip file.
zooba commentedon Jun 3, 2026
@zware FYI (you can have first go at it, but if you haven't got the time then just say and I'm sure someone else will have time)
zware commentedon Jun 3, 2026
If someone can beat me to it, go for it :)
jjhelmus commentedon Jun 3, 2026
FWIW I think the Tcl library loads because it is embedded in the DLL:
jjhelmus commentedon Jun 3, 2026
A bit more information. The tk_library is embedded in
tcl9tk90.dll:The DLLs directory does not seem to be searched by Tcl's tcl_findLibrary. Moving
tcl9tk90.dllup one directory so it is next to python.exe fixes the issue but is not a solution.Building tcl/tk with
noembedlooks promising. I'm trying that out locally.jjhelmus commentedon Jun 4, 2026
Building Tcl/Tk with the
noembedoption copies the Tcl and Tk core library scripts into the install target using the same layout as Tcl/Tk 8.6, e.g.<arch>/lib/{tcl,tk}9.0/. This allows tkinter to find these script at runtime.The default
embedoption embeds a zip archive with these scripts into the DLLs themselves. This leads to the issue observed here as Tcl does not search the Tk DLL for scripts.nibedanmohanta9-arch commentedon Jun 5, 2026
7 remaining items
zooba commentedon Jun 17, 2026
Thanks @jjhelmus, I like how that looks, and it ought to be more future proof, if I understand correctly? Interested in others' thoughts as well.
I'll leave a comment or two on that PR, since I think it's worth making it ready to merge, but my other big question is whether this should be used on all platforms? Is this a Windows-only feature from Tcl, or is there benefit to mounting it on all OSs?
jjhelmus commentedon Jun 18, 2026
I suspect other platform would benefit from mounting the Tk DSO/DLL if it contained an embedded tk_library. Especially if the CPython install is relocated or determined at install time rather that build time. I need to do some testing to see if the current situation causes problems. Most distributions I know of either us a hardcoded path to the Tk library (e.g. Linux distro provided CPython) or disable embedding (python-build-standalone, MacPorts) which avoids the issue seen here.
jjhelmus commentedon Jun 18, 2026
I tested out linking Tcl/Tk with embedded library on both macOS and Linux in python-build-standalone and neither have issues with Tkinter, it seems like this issue is limited to Windows.
Specifically Tcl uses the executable relative fallback in
tcl_findLibraryto find the DSOs with the embedding in<prefix>/libwhen the executable (python) is in<prefix>/bin.zooba commentedon Jun 19, 2026
Well, it sounds like @jjhelmus has the only opinion here (other than me), so let's go with doing the mount on Windows only and see what comes out of it.
gh-150836: Mount embedded Tk ZIP in _tkinter on Windows (GH-151562)
[3.15] gh-150836: Mount embedded Tk ZIP in _tkinter on Windows (GH-15…
hugovk commentedon Jun 22, 2026
Thanks all, I've removed the release-blocker label.
zooba commentedon Jun 22, 2026
Closing this as completed, we can reopen if it is still busted.
terryjreedy commentedon Jun 22, 2026
IDLE is working fine. There is still an open PR. Was it superceded? Should it be closed?
zooba commentedon Jun 22, 2026
Yes, and not yet (unless you're confident enough that this fix will work after install to go and close the other one).
pythongh-150836: Mount embedded Tk ZIP in _tkinter on Windows (python…
pythongh-150836: Mount embedded Tk ZIP in _tkinter on Windows (python…