为可执行文件指定与可执行脚本名称不同的名称

发布于 2024-10-22 19:20:27 字数 1040 浏览 3 评论 0原文

我正在使用以下安装文件来使用 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 重命名可执行文件,但脚本无法正常工作,因为脚本被包模块进一步引用。

I am using the following setup file to create executable using cx_freeze. Is it possible to generate the exe with a different name other than the name of the executable script?

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")]                
     )  

So now the exe which is created has name runner.exe and i want it to be something different like myexecutable.exe Renaming the executable, ir the script is not working cause the script is further referenced by the package modules.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

与君绝 2024-10-29 19:20:27

尝试使用 targetName 选项:

executables = [Executable(targetName="myexecutable.exe")]

较新的版本请改用 target_name,因此,如果您使用的是最新的 cx_Freeze 版本,请改用

executables = [Executable(target_name="myexecutable.exe")]

Try using the targetName option:

executables = [Executable(targetName="myexecutable.exe")]

more recent version use target_name instead, so if you're on the latest cx_Freeze version, instead use

executables = [Executable(target_name="myexecutable.exe")]
谁人与我共长歌 2024-10-29 19:20:27

新的关键字样式是 target_name

executables = [Executable(target_name="myexecutable.exe")]

The new style of keyword is target_name

executables = [Executable(target_name="myexecutable.exe")]
温暖的光 2024-10-29 19:20:27

只需在其中使用关键字“target_name”
Executable(target_name = "my_executable")

根据操作系统 windows 或 linux 保留可执行文件的名称

Just use the keyword "target_name" inside the
Executable(target_name = "my_executable")

keep the name of your executable file as per the OS windows or linux

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文