自己试验py2exe的脚本,做个记录: 一、控制台程序的 # -*- coding: utf-8 -*- from distutils.core import setup import py2exe import sys if len(sys.argv) == 1: sys.argv.append("py2exe") sys.argv.append("-q") setup(console=['Test.py']) 二、带Qt库的gui程序 # -*- coding: utf-8 -*- """ py2exe的样本程序 """ from distutils.core import setup import py2exe import sys if len(sys.argv) == 1: sys.argv.append("py2exe") sys.argv.append("-q") includes = ["encodings", "encodings.*", "sip"] #excludes = ["pywin", "pywin.debugger", "pywin.debugger.dbgcon", # "pywin.dialogs", "pywin.dialogs.list", "win32com.server"] options = {"py2exe": { "compressed": 1, "optimize": 2, "includes": includes, #"excludes": excludes, "bundle_files": 1, "dll_excludes": ["w9xpopen.exe"] # we don't need this } } setup( version = "0.1.0", description = "Hello Eric Test!", name = "HelloEric", options = options, zipfile=None, author = "Junhe.Tan", windows=[{"script": "HelloEric.py", "script":"Ui_HelloEric.py", "icon_resources": [(1, "guitar.ico")] }], )