I've been taking this Python Course for a couple of days and now I am stuck in this part of the exercise for downloading and running FreeSimpleGUI along with other archives with Pycharm.
I used the codes below:
import functions
import FreeSimpleGUI
I have installed the 3.13.0 version of Python and the 5.1.1 version of FreeSimpleGUI. Also installed and uninstalled multiple times the same and other versions of these programs.
I am very new to Python so I don't know what exactly to do.
I expected the module to run properly like in the video ("Process finished with exit code 0") but it produced the next error:
Traceback (most recent call last):
File "C:\Users\Aliss\PycharmProjects\PythonProject2\gui.py", line 2, in <module>
import FreeSimpleGUI
File "C:\Users\Aliss\PycharmProjects\PythonProject\.venv\Lib\site-packages\FreeSimpleGUI\__init__.py", line 41, in <module>
tclversion_detailed = tkinter.Tcl().eval('info patchlevel')
~~~~~~~~~~~^^
File "C:\Users\Aliss\AppData\Local\Programs\Python\Python313\Lib\tkinter\__init__.py", line 2572, in Tcl
return Tk(screenName, baseName, className, useTk)
File "C:\Users\Aliss\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/Aliss/AppData/Local/Programs/Python/Python313/lib/tcl8.6 C:/Users/Aliss/PycharmProjects/PythonProject/.venv/lib/tcl8.6 C:/Users/Aliss/PycharmProjects/PythonProject/lib/tcl8.6 C:/Users/Aliss/PycharmProjects/PythonProject/.venv/library C:/Users/Aliss/PycharmProjects/PythonProject/library C:/Users/Aliss/PycharmProjects/PythonProject/tcl8.6.14/library C:/Users/Aliss/PycharmProjects/tcl8.6.14/library
This probably means that Tcl wasn't installed properly.
The error you’re encountering is due to a missing or improperly installed Tcl/Tk dependency, which Python’s tkinter (and thus FreeSimpleGUI) relies on. To resolve this, start by uninstalling Python 3.13.0, as it may be an unstable or development version with incomplete Tcl/Tk support. Instead, download and install a stable release like Python 3.11.x or 3.12.x from the official Python website. During installation, ensure the option to install Tcl/Tk and IDLE is checked—this is critical for GUI libraries to work. After reinstalling Python, test if tkinter is functional by running a simple script like import tkinter as tk; root = tk.Tk(); root.mainloop(). If a blank window appears, Tcl/Tk is installed correctly.
Next, set up a new project in PyCharm using a virtual environment to isolate dependencies. In PyCharm, navigate to File > Settings > Project > Python Interpreter, and ensure the interpreter points to your newly installed Python version (e.g., C:\Python312\python.exe). Install FreeSimpleGUI within this environment using the PyCharm terminal with pip install FreeSimpleGUI.
If the Tcl error persists, manually check your Python installation’s tcl folder (e.g., C:\Python312\tcl). Confirm it contains subfolders like tcl8.6 and tk8.6. If these are missing, reinstall Python and explicitly enable Tcl/Tk during setup. If the folders exist but the error remains, set environment variables to guide Python to the Tcl/Tk files: define TCL_LIBRARY as C:\Python312\tcl\tcl8.6 and TK_LIBRARY as C:\Python312\tcl\tk8.6 (adjust the path to match your Python version).
Finally, test your FreeSimpleGUI code with a minimal example like:
import FreeSimpleGUI as sg
layout = [[sg.Text("Hello!")], [sg.Button("OK")]]
window = sg.Window("Demo", layout)
event, values = window.read()
window.close()
If a window appears, the issue is resolved. This problem often stems from incomplete Python installations or virtual environments inheriting broken paths. Ensuring Tcl/Tk is properly installed and referenced should fix the error.