多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
有个好网站[http://www.lfd.uci.edu/~gohlke/pythonlibs/](http://www.lfd.uci.edu/~gohlke/pythonlibs/) , 这个网站可以下载许多非官方的python库的安装包。 1.首先去这个网站下载cx_freeze安装包后安装。 2.在C:\PythonXX\Scripts\ 下可以看到cxfreeze-quickstart.bat, XX为版本号 3.运行cxfreeze-quickstart.bat, 根据向导生成setup.py     setup.py类似如下: > > import sys > > from cx_Freezeimportsetup, Executable > > # Dependencies are automatically detected, but it might need > # fine tuning. > > buildOptions = dict(packages = [], excludes = [], include_files={ "DcmStatistics.xsd","dcm2xml.exe","readme.txt","DcmStatisticsResult.xslt"}) > > > executable = "DcmFileCompareTool.py" > > base = 'Console' > > targetName = "dcmAnalyzer.exe" > > executables = [ >     Executable(executable, base=base, targetName=targetName) > ] > > > setup(name= 'dcmanalyzer', > >       version = '1.0', > >       description = 'convert dcm file to xml, parse xml and create statistics result, arrange dcm file to folders of different companies.', >       options = dict(build_exe = buildOptions), >       executables = executables) 4.executable指定py主文件, base指定生成Exe的类型(Console、Win32GUI)【在C:\PythonXX\Lib\site-packages\cx_Freeze\bases可以看到】, targetName指定生成exe的名字。 include_files指定打包一起的文件。 5.写个setup.bat, 执行编译 > > python setup.py build > > pause 6.注意,有时打包出来的exe运行错误, 提示缺少inspect,解决办法:    在py主文件的头部添加import inspect > > > > > > >