cxfreeze打包过程中最好通过setup.py来进行打包,打包的python程序需由模块+单个文件方式进行组织,否则会出现导入错误(ImportError),打包的setup.py配置如下:
# coding=utf-8
from cx_Freeze import setup, Executable
# python setup.py build
includefiles = ['README.md', 'event.ini'];;配置文件不用打包,相对路径
includes = []
excludes = []
packages = ['openpyxl', 'aiohttp', 'xlrd']
setup(name = "simple" ,
version = "0.1" ,
description = "A event export" ,
author = "wyt",
author_email = "test@qq.com",
options = {'build_exe': {'includes' :includes, 'excludes': excludes, 'packages' : packages, 'include_files': includefiles}},
executables = [Executable("main.py")]
)
通过python setup.py build来生成打包文件夹build。注意实现如下:
1. 打包后依赖的模块在lib文件夹