使用py2exe进行打包
例:
from distutils.core import setupimport py2exeimport sys
sys.argv.append(‘py2exe‘) py2exe_options = {
#调用的库 "includes": ["sip","pyxmpp","M2Crypto","dns","Skype4Py","libxmlmods","PyQt4",], "dll_excludes": ["MSVCP90.dll",], "compressed": 1, "optimize": 2, "ascii": 0, "bundle_files": 1, } setup( name = ‘PyQt Demo‘, version = ‘1.0‘,
#打包py文件和程序图标 windows = [{‘script‘:‘tunneler_client.py‘,‘icon_resources‘:[(1,"icon.ico")]}], zipfile = None, options = {‘py2exe‘: py2exe_options} )
对py文件打包后很难调试程序,可使用python的logging输出日志文件
logger = logging.getLogger()logger.addHandler(logging.StreamHandler()) #关闭和开启日志输出
时间: 2024-10-27 04:10:46