Repository navigation
Closed as not planned
Labels
OS-windowstopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
import PySimpleGUIor
import FreeSimpleGUIresults in the following Traceback (for import PySimpleGUI):
Traceback (most recent call last):
File "c:\Users\charl\PYTHON\stackoverflow_questions_2\test_PySimpleGUI_re_tkinter.py", line 4, in <module>
import PySimpleGUI
File "C:\Users\charl\PYTHON\stackoverflow_questions_2\.venv313\Lib\site-packages\PySimpleGUI\__init__.py", line 1, in <module>
from .PySimpleGUI import *
File "C:\Users\charl\PYTHON\stackoverflow_questions_2\.venv313\Lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 108, in <module>
tclversion_detailed = tkinter.Tcl().eval('info patchlevel')
~~~~~~~~~~~^^
File "C:\Users\charl\AppData\Local\Programs\Python\Python313\Lib\tkinter\__init__.py", line 2572, in Tcl
return Tk(screenName, baseName, className, useTk)
File "C:\Users\charl\AppData\Local\Programs\Python\Python313\Lib\tkinter\__init__.py", line 2459, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
C:/Users/charl/AppData/Local/Programs/Python/Python313/lib/tcl8.6 C:/Users/charl/PYTHON/stackoverflow_questions_2/.venv313/lib/tcl8.6 C:/Users/charl/PYTHON/stackoverflow_questions_2/lib/tcl8.6 C:/Users/charl/PYTHON/stackoverflow_questions_2/.venv313/library C:/Users/charl/PYTHON/stackoverflow_questions_2/library C:/Users/charl/PYTHON/stackoverflow_questions_2/tcl8.6.14/library C:/Users/charl/PYTHON/tcl8.6.14/library
This probably means that Tcl wasn't installed properly.This does not occur using python 3.12.7
It can be worked around using the following code:
import os
os.environ['TCL_LIBRARY'] = r'C:\Users\charl\AppData\Local\Programs\Python\Python313\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\charl\AppData\Local\Programs\Python\Python313\tcl\tk8.6'CPython versions tested on:
3.13
Operating systems tested on:
Windows
Metadata
Metadata
Assignees
Labels
OS-windowstopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
Xiaokang2022 commentedon Nov 7, 2024
I'm having a similar issue, only in Python 3.13.0 (Windows). But it doesn't seem like this problem will come up every time, it's weird.
At first, I thought it was something wrong with my environment, but now it seems that I'm not the only one who has encountered it. By the way, I ran into this issue when I was using
pytestto test code related totkinter.[-]When importing PySimpleGUI or FreeSimpleGUI, python ends with "_tkinter.TclError: Can't find a usable init.tcl in the following directories:" [/-][+]tkinter.Tk() sometimes fails[/+]terryjreedy commentedon Nov 7, 2024
Closing as a duplicate of #118973 (tkinter fails in installed free-threading build) or, more likely here, #125235 (tkinter fails in venv). Fix for latter in 3.13.1.
test: reuse one Tcl interpreter in GUI smoke tests