这可能看起来像一个重复的问题,但我已经经历了所有其他线程并且无法让我的去,所以这里是:

我基本上使用文本框,标签,图像,按钮构建了一个python 3 tkinter UI,我正在尝试将其作为.exe文件 . 现在尝试先测试一下,我制作了一个骨架tkinter代码,它是:

import tkinter 
top = tkinter.Tk()
top.mainloop()

我从另一个stackoverflow线程中执行了以下步骤:( Maria Irudaya的最佳答案)How can I convert a .py to .exe for Python?

我的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:\UI\tkinter_test\build\exe.win-amd64-3.6>tkinter_test.exe
Traceback (most recent call last):
  File "C:\Users\kumsv\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
    module.run()
  File "C:\Users\kumsv\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
    exec(code, m.__dict__)
  File "tkinter_test.py", line 1, in <module>
  File "C:\Users\kumsv\AppData\Local\Programs\Python\Python36\lib\tkinter\__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技术之前完成了它,请帮助,谢谢!

EDIT :找到解决方案,我不得不将我的python目录的DLLs文件夹中的tk86t.dll和tcl86t.dll文件复制到我正在尝试编译的.py的build文件夹中 .