简体   繁体   English

将tkinter文件转换成.exe Python 3

[英]Convert tkinter file into .exe Python 3

This might look like a duplicate question, but I have pretty much gone through all other threads and couldn't get mine going, so here goes:这可能看起来像一个重复的问题,但我几乎已经遍历了所有其他线程并且无法继续我的,所以这里是:

I have basically built a python 3 tkinter UI using text box, labels, images, buttons and I am trying to make this an.exe file.我基本上使用文本框、标签、图像、按钮构建了一个 python 3 tkinter UI,我正在尝试制作这个 an.exe 文件。 Now to try and test this first I made a skeleton tkinter code which is:现在首先尝试测试这个,我制作了一个框架 tkinter 代码,它是:

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

I followed these steps from another stackoverflow thread: (Top answer by Maria Irudaya) How can I convert a.py to.exe for Python?我按照另一个 stackoverflow 线程的这些步骤操作:(Maria Irudaya 的最佳答案) 如何将 a.py 转换为 Python 的 .exe?

My setup.py is:我的 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
)

I followed these step by step and got a directory error for tcl tkl and I went past it by changing them to the Python35-32 directory, now the file is building but its not displaying anything.我一步一步地按照这些步骤进行操作,得到了一个 tcl tkl 的目录错误,我通过将它们更改为 Python35-32 目录来解决这个问题,现在文件正在构建但它没有显示任何内容。 (It was supposed to open the blank UI with nothing inside it.) It opens and goes off in a flash. When I try to run it using cmd, I get: (它应该打开里面什么都没有的空白用户界面。)它在 flash 中打开和关闭。当我尝试使用 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.

I just want to convert my tkinter Python 3 file into a .exe file (Not necessarily by cx_freeze) so if someone has done it before with similar tkinter technicalities.我只想将我的 tkinter Python 3 文件转换为.exe文件(不一定由 cx_freeze),所以如果有人以前用类似的 tkinter 技术做过。

Copy the tk86t.dll and tcl86t.dll files from your python directory's DLLs folder into the build folder with the .py you are trying to compile.tk86t.dlltcl86t.dll文件从 python 目录的 DLLs 文件夹复制到包含您要编译的.py的构建文件夹中。

as per OP @Krishnakumar M's prior edit to the question.根据 OP @Krishnakumar M 对问题的先前编辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM