【问题标题】:How to build single .exe file with multiple files in python using cx_freeze如何使用 cx_freeze 在 python 中构建具有多个文件的单个 .exe 文件
【发布时间】:2017-05-28 00:43:43
【问题描述】:

使用 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 文件没有按预期工作 [它只是在几毫秒内启动并关闭 cmd]

请让我知道我在这方面做错了什么?

【问题讨论】:

  • 你试过通过命令提示符启动 exe 吗?
  • 是的,我已经尝试过,但遇到了导入错误。文件“C:\Users\administrator\AppData\Local\Programs\Python\Python35\lib\s te-packages\xlwt-1.2.0-py3.5.egg\xlwt\ExcelFormula.py”第 3 行,在模块> 从 .导入 ExcelFormulaParser,ExcelFormulaLexer 导入错误:无法导入名称“ExcelFormulaParser”
  • 我会把它包括在问题中

标签: python python-3.x cx-freeze


【解决方案1】:

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

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

【讨论】:

  • 谢谢.. 在安装文件中包含软件包后,它对我有用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-27
  • 1970-01-01
  • 1970-01-01
  • 2017-12-24
  • 2021-10-12
  • 1970-01-01
相关资源
最近更新 更多