好解决了:
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')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)