可以用如下命令打包
nuitka --mingw64 --standalone --windows-disable-console --show-memory --enable-plugin=tk-inter --nofollow-imports --follow-import-to=utils,src --output-dir=out --windows-icon-from-ico=logo.png xxx.py
先介绍以下nuitka的打包命令:
- –mingw64 默认为已经安装的vs2017去编译,否则就按指定的比如mingw(官方建议)
- –standalone 独立环境,这是必须的(否则拷给别人无法使用)
- –windows-disable-console 没有CMD控制窗口
- –output-dir=out 生成exe到out文件夹下面去
- –show-progress 显示编译的进度,很直观
- –show-memory 显示内存的占用
- –include-qt-plugins=sensible,styles 打包后PyQt的样式就不会变了
- –plugin-enable=qt-plugins 需要加载的PyQt插件
- –plugin-enable=tk-inter 打包tkinter模块的刚需
- –plugin-enable=numpy 打包numpy,pandas,matplotlib模块的刚需
- –plugin-enable=torch 打包pytorch的刚需
- –plugin-enable=tensorflow 打包tensorflow的刚需
- –windows-icon-from-ico=你的.ico 软件的图标
- –windows-company-name=Windows下软件公司信息
- –windows-product-name=Windows下软件名称
- –windows-file-version=Windows下软件的信息
- –windows-product-version=Windows下软件的产品信息
- –windows-file-description=Windows下软件的作用描述
- –windows-uac-admin=Windows下用户可以使用管理员权限来安装
- –linux-onefile-icon=Linux下的图标位置
- –onefile 像pyinstaller一样打包成单个exe文件(2021年我会再出教程来解释)
- –include-package=复制比如numpy,PyQt5 这些带文件夹的叫包或者轮子
- –include-module=复制比如when.py 这些以.py结尾的叫模块
- –show-memory 显示内存
- –show-progress 显示编译过程
- –follow-imports 全部编译
- –nofollow-imports 不选,第三方包都不编译
- –follow-stdlib 仅选择标准库
- –follow-import-to=MODULE/PACKAGE 仅选择指定模块/包编译
- –nofollow-import-to=MODULE/PACKAGE 选择指定模块/包不进行编译