Search code examples
pythonpython-3.xcx-freeze

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


Using Python 3.5 and cx_freeze 5.0.1

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

I am trying to create single .exe file for Main_file.py which is imported with [Log.py,ExcelOperations.Py and OS, subprocess,configparser are imported in Main_file.py file]

My Setup.py file

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)])

# After creating build with above setup file my Main_file.exe file is not working as expected [It just launches and closes the cmd in a mili sec]

Please let me know what am I doing wrong in this?


Solution

  • It looks like cx_freeze isn't collecting all of the required modules for the xlwt package. Try editing your build_exe_options variable to include the xlwt package

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