参考https://zhuanlan.zhihu.com/p/141810934、https://zhuanlan.zhihu.com/p/133303836
安装mingw,路径没关系,直接设置环境变量到gcc.exe。测试mingw环境
https://sourceforge.net/projects/mingw-w64/files/
安装nuitka:pip install nuitka
测试。如果出错了,卸载nuitka,然后以管理员方式打开cmd,重新安装一次。
编译py入口文件:nuitka –standalone –mingw64 –show-memory –show-progress –nofollow-imports –plugin-enable=qt-plugins –follow-import-to=xxx,xxx –output-dir=o xxx.py
一些参考的命令:
–mingw64 #默认为已经安装的vs去编译,否则就按指定的比如mingw
–standalone 独立文件,这是必须的
–windows-disable-console 没有CMD控制窗口
–recurse-all 所有的资源文件
–recurse-not-to=numpy,jinja2 不编译的模块,防止速度会更慢
–output-dir=out 生成exe到out文件夹下面去
–show-progress 显示编译的进度,很直观
–show-memory 显示内存的占用
–plugin-enable=pylint-warnings 报警信息
–plugin-enable=qt-plugins 需要加载的极速赛车稳赚4码
–recurse-all 所有的资源文件
–recurse-not-to=numpy,jinja2 不编译的模块,防止速度会更慢
–output-dir=out 生成exe到out文件夹下面去
–show-progress 显示编译的进度,很直观
–show-memory 显示内存的占用
–plugin-enable=pylint-warnings 报警信息
–plugin-enable=qt-plugins 需要加载的PyQT插件
依赖文件搜索问题:直接将exe拖入cmd,提示少什么就装什么。利用everthing搜索。记得备份,因为下次编译会清空输出目录。测试