cx_Freeze 无法使用 pandas 构建 msi

cx_Freeze not able to build msi with pandas

您好,我有以下 cx_Freeze setup.py 文件用于使用 pandas 模块。当我生成 msi 时,我遇到了问题。为此,我查看了整个 google,但其中 none 对我有用。

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

当我用 cx_Freeze==4.3.4 构建 msi 时,它给出了 此错误:

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

当我使用 cx_Freeze >= 5.0.0 时,会创建 msi 但安装后会出现

ImportError: Missing required dependencies['numpy']

我尝试了所有可用的堆栈溢出解决方法,但 none 正在工作任何建议都将是一个很大的帮助,在此先感谢。

pandas 依赖于 numpy,您需要将 numpy 显式添加到 build_exe 选项的 packages 列表中,以便 cx_Freeze正确包含 numpy,参见 Creating cx_Freeze exe with Numpy for Python

尝试将以下内容添加到您的设置脚本中

packages = ['numpy']

并根据

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