【问题标题】:Invalid command 'bdist_msi' when trying to create MSI installer with 'cx_Freeze'尝试使用 \'cx_Freeze\' 创建 MSI 安装程序时命令 \'bdist_msi\' 无效
【发布时间】:2022-11-17 17:19:17
【问题描述】:

我正在尝试使用 cx_Freeze 包为 Windows 创建 MSI 安装程序。无论如何,当运行命令 python setup.py bdist_msi 时,我得到一个错误,它是无效的。是否有任何我遗漏的选项,或者我可能无法在 Linux 上使用它(我使用的是 Debian 11)?

import sys
from pathlib import Path
from cx_Freeze import setup, Executable

company_name = '...'
product_version = '...'
product_name = '...'
product_description = '...'

base = None
build_exe_options = {}
bdist_msi_options = {
    'initial_target_dir': r'[ProgramFilesFolder]\%s\%s' % (company_name, product_name),
}

if sys.platform == 'win32':
    base = 'Win32GUI'

setup(
    name=product_name,
    version=product_version,
    description=product_description,
    options={
        'build_exe': build_exe_options,
        'bdist_msi': bdist_msi_options
    },
    executables=[Executable(
        'app.py',
        base=base,
        shortcut_name=product_name,
        shortcut_dir='DesktopFolder',
        icon=str(Path(__file__).parent / 'icon.jpg')
    )],
)

【问题讨论】:

    标签: python windows-installer


    【解决方案1】:

    根据 cx_Freeze 文档的 this 部分,交叉编译确实是不可能的。至少以通常的方式。

    cx_Freeze 适用于 Windows、Mac 和 Linux,但在每个平台上它 只生成在该平台上运行的可执行文件。所以如果你想 冻结你的 Windows 程序,在 Windows 上冻结它;如果你想 在 Mac 上运行它,在 Mac 上冻结它。

    在紧要关头,您可以尝试使用 Wine 制作 Windows 可执行文件。我们的 经验是你需要在之后手动复制一些文件 cx_Freeze 已运行以使可执行文件工作。我们不推荐这个 选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-23
      • 1970-01-01
      • 2018-04-11
      • 1970-01-01
      • 1970-01-01
      • 2018-08-05
      相关资源
      最近更新 更多