如何使用 cx_freeze 在 python 中构建包含多个文件的单个 .exe 文件

How to build single .exe file with multiple files in python using cx_freeze

使用 Python 3.5 和 cx_freeze 5.0.1

**MY Folder Structure :**
Main_file.py, 
Log.py, 
ExcelOperations.Py, 
TestData.xlsx, 
Config.ini,  
PsExec.exe (For remote execution) 

我正在尝试为 Main_file.py 创建单个 .exe 文件,该文件使用 [Log.py、ExcelOperations.Py 和 OS 导入,子进程、configparser 导入到 Main_file.py文件]

我的 Setup.py 文件

import sys
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}
base = None
setup( name = "guifoo",
    version = "0.1",
    description = "My GUI application!",
    options = {"build_exe": build_exe_options},
    executables = [Executable("Main_file.py", base=base)])

# 使用上述设置文件创建构建后,我的 Main_file.exe 文件没有按预期工作 [它只是在 mili 秒内启动和关闭 cmd]

请告诉我我做错了什么?

看起来 cx_freeze 没有收集 xlwt 包所需的所有模块。尝试编辑您的 build_exe_options 变量以包含 xlwt 包

build_exe_options = {"packages": ["os", "xlwt"], "excludes": ["tkinter"]}