Search code examples
pythonpandascx-freeze

cx_Freeze not able to build msi with pandas


Hi I have following cx_Freeze setup.py file for an application that uses pandas module. When I generate msi I am facing issues. I looked all over the google for this but none of them are working for me.

include-files = ['aardvark.dll'] 
includes = []
excludes = []

base = "Win32GUI"
exe = Executable( 
    script="test.py",
    initScript=None,
    base=base,
    targetName="test.exe",
    copyDependentFiles=True,
    compress=False,
    appendScriptToExe=False,
    appendScriptToLibrary=False,
    shortcutDir="MyProgramMenu",
    shortcutName=APP_NAME)
bdist_msi_options = {
    "upgrade_code": UPGRADE_CODE,
    "add_to_path" : False}
setup( 
    name=APP_NAME,  
    version=VERSION,
    author="sri",
    description='test Tool',
    options={"build_exe": {"excludes":excludes,
    "includes":includes,
    "include_files":includefiles},
    "bdist_msi" : bdist_msi_option},
    executables=[exe])

When I build msi with cx_Freeze==4.3.4 it gives this error:

cx_Freeze.freezer.ConfigError: no file named sys (for module collections.sys)

and when I use cx_Freeze >= 5.0.0 the msi is created but after installing this gives

ImportError: Missing required dependencies['numpy']

enter image description here

I tried all the available stack overflow work around but none of them is working any suggestion will be a great help thanks in advance.


Solution

  • pandas depends on numpy and you need to explicitly add numpy to the packages list of the build_exe options in order that cx_Freezeincludes numpycorrectly, see Creating cx_Freeze exe with Numpy for Python

    Try to add the following to your setup script

    packages = ['numpy']
    

    and to modify the options according to

    options={"build_exe": {"excludes":excludes,
                           "includes":includes,
                           "include_files":includefiles,
                           "packages":packages},
             "bdist_msi" : bdist_msi_option},