【问题标题】:cx_Freeze: shortcutDir gives errorcx_Freeze:shortcutDir 给出错误
【发布时间】:2016-12-02 21:40:27
【问题描述】:

我正在为我的 Python 程序创建单个文件 exe。我正在使用 cx_Freeze。 一切都很完美,除了一点点烦人的事情。

当我安装我的程序时,一切都会按照应有的方式安装,包括我桌面上的快捷方式。

但是...当我想使用桌面上的快捷方式启动程序时,出现以下错误:

当我尝试从我的程序文件夹中运行我的程序时,它可以正常工作。 当我手动创建桌面快捷方式时,它也能正常工作。

有谁知道为什么安装我的程序时安装的快捷方式不起作用?

我的 cx_Freeze setup.py

import cx_Freeze
import sys

executables = [cx_Freeze.Executable("Tennis_Calculator.py", base="Win32GUI", icon="tennis_ball.ico", shortcutName="TPC", shortcutDir="DesktopFolder")]
build_exe_options = {"icon": "tennis_ball.ico","packages":["Tkinter", "csv", "ttk"], "include_files":["tennis_ball.ico", "testtennis.csv"]}
build_msi_options = {"include_files":"testtennis.csv"}


cx_Freeze.setup(
    name = "Tennis Probability Calculator",
    options = {"build_exe":build_exe_options, "build_msi":build_msi_options},
    version = "1.0",
    author = "WS",

    executables = executables
    )

【问题讨论】:

    标签: python cx-freeze


    【解决方案1】:

    经过长时间的搜索,我找到了解决方案。

    How to set shortcut working directory in cx_freeze msi bundle?

    我可以通过对 cx_Freeze/windist.py 进行一些小改动来解决这个问题。在 add_config() 的第 61 行,我更改了:

    msilib.add_data(self.db, "Shortcut",
            [("S_APP_%s" % index, executable.shortcutDir,
                    executable.shortcutName, "TARGETDIR",
                    "[TARGETDIR]%s" % baseName, None, None, None,
                    None, None, None, None)])
    

    到

    msilib.add_data(self.db, "Shortcut",
            [("S_APP_%s" % index, executable.shortcutDir,
                    executable.shortcutName, "TARGETDIR",
                    "[TARGETDIR]%s" % baseName, None, None, None,
                    None, None, None, "TARGETDIR")]) # <--- Working directory.
    

    谢谢大家。

    【讨论】:

      猜你喜欢
      • 2017-12-20
      • 2012-09-25
      • 2013-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多