sar*_*678 3 python tkinter pyinstaller python-2.7
我已经在 python 中创建了一个 GUI(使用 Tkinter),并且使用 os.system('python_file.py') 从 GUI 单击按钮即可运行 python 文件。我想使用 pyinstaller 将所有这些 python 文件捆绑到单个 .exe 文件中,并将 Tkinter 文件保留为主文件。
我通过在命令行中执行以下操作创建了 .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 )
Run Code Online (Sandbox Code Playgroud)
我不确定如何将其他 python 文件包含在上面的 .spec 文件中,以便整个应用程序正常工作。有人可以帮忙吗?
小智 5
假设您有两个文件:"my_main.py"和"my_functions.py"。假设“my_main.py”从“my_functions.py”导入方法
执行以下命令:
pyinstaller --onefile my_main.py my_functions.py
生成的单个可执行文件“my_main.exe”将在当前工作目录的“dist”文件夹下创建。
Linux/Windows 的过程相同。对于两个以上的 python 文件,只需将它们包含在其中并用空格分隔即可。
pyinstaller --onefile my_main.py my_functions.py file3.py file4.py
| 归档时间: |
|
| 查看次数: |
18969 次 |
| 最近记录: |