2016-07-28 114 views
1

我正在爲我的Python程序創建單個文件exe。我正在使用cx_Freeze。 除了一件煩人的事情之外,一切都很完美。cx_Freeze:shortcutDir給出錯誤

當我安裝我的程序時,所有的事情都會按照它應該做的那樣進行安裝,包括桌面上的快捷方式。

但是...當我想用桌面我得到以下錯誤上的快捷方式啓動程序:

Error

當我試圖從比我的程序文件夾中運行我的程序作品。 當我手動創建到桌面的快捷方式比它的工作。

有誰知道爲什麼在安裝我的程序時安裝的快捷方式不起作用?

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 
    ) 

回答

0

經過長時間的搜尋後,我找到了解決辦法。

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. 

謝謝大家。