# -*- coding: utf-8 -*-
#import distutils
#import py2exe
#from distutils.core import setup
#distutils.core.setup(windows=['first_app.py'])
#setup(console=[r’C:UsersliumingjieDesktopfirst_app.py’])
from distutils.core import setup
import sys
import py2exe
includes = ["encodings","encodings.*"]
sys.argv.append("py2exe")
options = {"py2exe":{"bundle_files":1}}
options = {"py2exe": {"compressed": 1, #压缩 "optimize": 2, "ascii": 1, "includes":includes, "bundle_files": 3 #所有文件打包成一个exe文件 } }
setup(
options = options,
zipfile = None,
description = "this is a py2exe test",
version = "0.1.0",
name = "search panda",
windows = [
{ "script": "first_app.py", "icon_resources": [(1, "hw.ico")] } ], )
关于python程序打包的问题整个程序有多个py文件,如何打包成一个exe文件?哪个工具比较好用些
用py2exe setup.py与主程序入口文件放同级目录下,options = {"py2exe": {"compressed": 1,
"optimize": 0,
"packages":[
这里放你的包 ],
"includes":[], "dist_dir":xxx}},。。。。。。。。。。。。
py2exe.
给你个例子
Python code
from distutils.core import setup import os import py2exe import pymssql data_files = [] data_files.append(os.path.join(os.path.split(pymssql.__file__)[0], 'ntwdblib.dll')) py2exe_options = {"includes": ['decimal','sqlalchemy.dialects.mssql','pyodbc']} setup(console=["com/engine/crawl.py"], options={"py2exe": py2exe_options}, data_files=data_files)
py2exe不仅可以包含py文件,还可以包含其他文件,比如
setup(console=["hello.py", "hello1.py"], windows=["hello2.py"],
data_files=[("img",
[r"d:documentsmatrix.jpg",
r"d:documentsBatman.jpg"]),
("xml",
[r"D: mpmypaint.xml",
r"D: mpmypuzzle.xml",
r"D: mpmypuzzle1.xml"])])