cx_Freeze:shortcutDir给出错误 [英] cx_Freeze: shortcutDir gives error

查看:76
本文介绍了cx_Freeze:shortcutDir给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的Python程序创建一个文件exe。我正在使用cx_Freeze。
除了一件令人讨厌的小东西,其他所有东西都可以正常工作。

I'm creating a single file exe for my Python program. I'm using cx_Freeze. Everything works perfect except one little annoying thing.

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

When I install my program everything installs as it should do, including the shortcut on my desktop.

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

BUT...When I want to start the program with the shortcut on the desktop I get the following error:

当我尝试从程序文件夹中运行程序时,无法正常运行。
当我手动创建桌面快捷方式而不是它的正常工作时。

When I try to run my program from within my program folder than it works. When I manually create a shortcut to the desktop than it works aswell.

有人知道为什么在我的程序安装时安装的快捷方式没有作用吗?

Does anyone know why the shortcut, which is installed at the installation of my program doesn't work?


我的cx_Freeze setup.py

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


推荐答案

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

After a long search I found a solution.

如何在cx_freeze msi捆绑包中设置快捷方式工作目录?

我能够通过对cx_Freeze / windist.py进行小的更改来解决此问题。在add_config()的第61行中,我更改了:

I was able to fix the problem by making a small change to cx_Freeze/windist.py. In add_config(), line 61, I changed:

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.

谢谢大家。

这篇关于cx_Freeze:shortcutDir给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆