这可能看起来像一个重复的问题,但我几乎已经浏览了所有其他线程并且无法继续我的线程,所以这里是:
我基本上使用文本框,标签,图像,按钮构建了一个python 3 tkinter UI,我正在尝试将其设置为.exe文件。现在为了首先尝试测试这一点,我制作了一个骨架 tkinter 代码,它是:
import tkinter
top = tkinter.Tk()
top.mainloop()
我从另一个堆栈溢出线程中执行了以下步骤: (玛丽亚·伊鲁达亚的热门回答( 如何将 Python 的.py转换为 .exe?
我 setup.py 是:
from cx_Freeze import setup, Executable
base = None
executables = [Executable("tkinter_test.py", base=base)]
packages = ["idna","tkinter"]
options = {
'build_exe': {
'packages':packages,
},
}
setup(
name = "tkinter_test",
options = options,
version = "1",
description = 'test',
executables = executables
)
我一步一步地按照这些步骤进行操作,并得到了 tcl tkl 的目录错误,我通过将它们更改为 Python35-32 目录来绕过它,现在文件正在构建,但它没有显示任何内容。(它应该打开空白 UI,里面什么都没有。它打开并在瞬间熄灭。当我尝试使用 cmd 运行它时,我得到:
C:UItkinter_testbuildexe.win-amd64-3.6>tkinter_test.exe
Traceback (most recent call last):
File "C:UserskumsvAppDataLocalProgramsPythonPython36libsite-packagescx_Freezeinitscripts__startup__.py", line 14, in run
module.run()
File "C:UserskumsvAppDataLocalProgramsPythonPython36libsite-packagescx_FreezeinitscriptsConsole.py", line 26, in run
exec(code, m.__dict__)
File "tkinter_test.py", line 1, in <module>
File "C:UserskumsvAppDataLocalProgramsPythonPython36libtkinter__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: DLL load failed: The specified module could not be found.
我只想将我的 tkinter Python 3 文件转换为.exe
文件(不一定是 cx_freeze(,所以如果有人以前用类似的 tkinter 技术做过的话。
将 python 目录的 DLLs 文件夹中的tk86t.dll
和tcl86t.dll
文件复制到包含您尝试编译.py
的构建文件夹中。
根据OP @Krishnakumar M对该问题的先前编辑。