py2exe更改应用程序名称输出

时间:2014-03-31 15:19:27

标签: python py2exe

我正在开发我的第一个Python项目,我需要使用py2exe进行编译。我写了这个setup.py代码:

from distutils.core import setup
import py2exe
import sys
import os 

if len(sys.argv) == 1:
    sys.argv.append("py2exe")

setup( options = {"py2exe": {"compressed": 1, "optimize": 2,"dll_excludes": "w9xpopen.exe",'dist_dir': "myproject", "ascii": 0, "bundle_files": 1}},
       zipfile = None,

       console = [
        {
            "script": "myapplication.py",                    ### Main Python script    
            "icon_resources": [(0, "favicon.ico")]     ### Icon to embed into the PE file.
        }
    ],)

os.system('upx -9 dist/*.exe')
os.system("rmdir /s /q build")
os.system("del /q *.pyc")

设置代码正常,但我需要将已编译应用程序的名称从myapplication更改为project.exe。 py2exe的哪些选项会更改输出应用程序的名称?

1 个答案:

答案 0 :(得分:15)

"dest_base" : "app_name"添加到您的控制台字典中:

   console = [
    {
        "script": "myapplication.py",                    ### Main Python script    
        "icon_resources": [(0, "favicon.ico")], ### Icon to embed into the PE file.
        "dest_base" : "app_name"
    }]