【发布时间】:2017-12-24 06:53:27
【问题描述】:
我在 python 中创建了一个 GUI(使用 Tkinter),它通过使用 os.system('python_file.py') 从 GUI 中单击一个按钮来运行 python 文件。我想通过将 Tkinter 文件保持为主文件,使用 pyinstaller 将所有这些 python 文件捆绑到单个 .exe 文件中。
我通过在命令行中执行以下操作创建了 .exe 文件:
pyinstaller --debug --onefile --noupx tkinter_app.py
目前我的 .spec 文件如下所示:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['tkinter_app.py'],pathex=['C:\\test'],binaries=[],datas=[],
hiddenimports=[],hookspath=[],runtime_hooks=[],excludes=[], win_no_prefer_redirects=False,
win_private_assemblies=False, cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas, name='tkinter_app', debug=True, strip=False, upx=False,console=True )
我不确定如何在上述 .spec 文件中包含其他 python 文件,以便整个应用程序正常工作。有人可以帮忙吗?
【问题讨论】:
-
您可以按照以下步骤操作:stackoverflow.com/a/37140662/5114581
标签: python python-2.7 tkinter pyinstaller