cx_freeze和捆绑文件

cx_freeze和捆绑文件,第1张

cx_freeze和捆绑文件

好解决了:

1)setup.py

import sysfrom cx_Freeze import setup, ExecutableEXE1 = Executable(    # what to build    script = "foo.py",    initscript = None,    base = 'Win32GUI',    targetDir = "dist",    targetName = "foo.exe",    compress = True,    copyDependentFiles = True,    appendscriptToExe = True,    appendscriptToLibrary = False,    icon = 'foo.ico'    )setup(    version = "9999",    description = "...",    author = "...",    name = "...",    options = {"build_exe": {"includes": includes,       "excludes": excludes,       "packages": packages,       "path": sys.path,       "append_script_to_exe":False,       "build_exe":"dist/bin",       "compressed":True,       "copy_dependent_files":True,       "create_shared_zip":True,       "include_in_shared_zip":True,       "optimize":2,       }    },    executables = [EXE1]    )

2)foo.py标头:

import osimport sysif getattr(sys,'frozen',False):    # if trap for frozen script wrapping    sys.path.append(os.path.join(os.path.dirname(sys.executable),'bin'))    sys.path.append(os.path.join(os.path.dirname(sys.executable),'bin\library.zip'))    os.environ['TCL_LIBRARY'] = os.path.join(os.path.dirname(sys.executable),'bin\tcl')    os.environ['TK_LIBRARY'] = os.path.join(os.path.dirname(sys.executable),'bin\tk')    os.environ['MATPLOTLIBDATA'] = os.path.join(os.path.dirname(sys.executable),'bin\mpl-data')


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5667573.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存