我正在尝试使用以下代码导入 FreeSimpleGUI 来创建桌面 GUI:
import FreeSimpleGUI
该代码产生以下错误:
Traceback (most recent call last):
File "C:\Users\tleak\PythonProjects\todo_app\gui.py", line 2, in <module>
import FreeSimpleGUI
File "C:\Users\tleak\PythonProjects\todo_app\venv\bin\python\Lib\site-packages\FreeSimpleGUI\__init__.py", line 2, in <module>
from .FreeSimpleGUI import *
File "C:\Users\tleak\PythonProjects\todo_app\venv\bin\python\Lib\site-packages\FreeSimpleGUI\FreeSimpleGUI.py", line 45, in <module>
tclversion_detailed = tkinter.Tcl().eval('info patchlevel')
~~~~~~~~~~~^^
File "C:\Users\tleak\AppData\Local\Programs\Python\Python313\Lib\tkinter\__init__.py", line 2572, in Tcl
return Tk(screenName, baseName, className, useTk)
File "C:\Users\tleak\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/tleak/AppData/Local/Programs/Python/Python313/lib/tcl8.6 C:/Users/tleak/PythonProjects/todo_app/venv/bin/python/lib/tcl8.6 C:/Users/tleak/PythonProjects/todo_app/venv/bin/lib/tcl8.6 C:/Users/tleak/PythonProjects/todo_app/venv/bin/python/library C:/Users/tleak/PythonProjects/todo_app/venv/bin/library C:/Users/tleak/PythonProjects/todo_app/venv/bin/tcl8.6.14/library C:/Users/tleak/PythonProjects/todo_app/venv/tcl8.6.14/library
This probably means that Tcl wasn't installed properly.
我希望代码能够成功导入 FreeSimpleGUI。我已经卸载了 Python 的所有内容并重新安装,以取消安装过多的 Python。如何解决此错误代码并成功导入 FreeSimpleGUI 以继续我的项目?
使用 python 3.12 可以避免这个问题
虽然FreeSimpleGUI声称兼容python 3.4+,但它显然不兼容python 3.13。