1,安装
官网下载 或者 pip install py2exe
2,准备脚本
import MySQLdb
import MySQLdb.cursors
import sys
....
3,准备安装脚本
import sys
from distutils.core import setup
import py2exe
includes = ["MySQLdb",]
options = {"py2exe": {"includes": includes,'bundle_files': 1, 'compressed': True}}
setup(
# The first three parameters are not required, if at least a
# 'version' is given, then a versioninfo resource is built from
# them and added to the executables.
# targets to build
console = ["dbExport.py"],
py_modules =['MySQLdb'],
options = options,
zipfile = None,
)
zipfile = None
表示生成单文件,没加的话会生成1.exe和libary.zip
setup.py py2exe
开始生成exe文件