时间:2021-02-07 14:48:59 | 栏目:Python代码 | 点击:次
背景:分享python编写的小脚本时,拷贝代码还缺各种环境,使用Pyinstaller将py可以打包成exe,直接运行即可
1、安装pyinstaller运行时所需要的windows拓展pywin32

2、安装pyinstaller
pip install pyinstaller

验证是否成功:pyinstaller -v

3、pyinstaller指令
| 参数 | 含 义 |
|---|---|
| -F | 只生成一个exe文件 |
| ?Cdistpath | 指定生成的exe存放的目录 |
| ?Cworkpath | 指定编译中临时文件存放的目录 |
| -D | 创建一个目录包含:exe文件、依赖文件 |
| -i | 指定exe图标 |
| -p | 指定exe依赖的包、模块 |
| -d | 编译为debug模式,获取运行中的日志信息 |
| -clean | 清理编译时临时文件 |
| -c | 使用控制台 |
| -w | 使用窗口 |
| -version-file | 添加exe版本信息 |
4、实例
pyinstaller -F .py全路径 ?Cdistpath exe存放目录

执行结果:
