给可执行文件起一个不同于脚本的名字
我正在使用以下的设置文件来通过cx_freeze创建可执行文件。请问能否生成一个不同于脚本名称的exe文件?
from cx_Freeze import setup, Executable
import xlrd
buildOptions = dict(
compressed = True,
optimize=2,
path=sys.path+[".\\uitls", “.\\supported”],
include_files=[“Doc"],
includes=[“xlrd”, "win32com"],
packages=["utils", ”supported"],
append_script_to_exe=True,
copy_dependent_files=True,
)
setup(
name = "TestExecutable",
version = "0.1",
options = dict(build_exe = buildOptions),
executables = [Executable(script=r".\\codebase\\runner.py",
icon=".\\icon.ico",
base="Win32GUI")]
)
现在生成的exe文件叫做runner.exe,但我想把它改成其他名字,比如myexecutable.exe。直接重命名可执行文件或脚本不起作用,因为这个脚本在包的模块中还有其他引用。
3 个回答
0
只需在 Executable(target_name = "my_executable")
中使用关键词 "target_name"
。
确保你的可执行文件名称符合操作系统的要求,比如 windows
或 linux
。
1
新的关键字风格是 target_name
executables = [Executable(target_name="myexecutable.exe")]
9
试试使用 targetName
这个选项:
executables = [Executable(targetName="myexecutable.exe")]