pyinstaller打包成exe
1、下载
pip install pyinstaller
2、常用参数说明
-F, --onefile 只创建一个可执行文件 -c, --console, --nowindowed 使用控制台(默认使用) -w, --windowed, --noconsole 不使用控制台 -i 指定图标
3、示例参考
示例一,py文件名称demo.py,内容只有一句print(5+8)
打包1:D:\Python37_64\Scripts\pyinstaller -F -c demo.py
现象1:打包完直接双击exe,出现控制台,出现11,然后退出
打包2:D:\Python37_64\Scripts\pyinstaller -F -w demo.py
现象2:打包完直接双击exe,鼠标转圈,然后结束
示例二:py文件名称demo.py,内容是写文件。
打包1:D:\Python37_64\Scripts\pyinstaller -F -c demo.py
现象1:打包完直接双击exe,出现控制台,然后退出,文件自动生成了
打包2:D:\Python37_64\Scripts\pyinstaller -F -w demo.py
现象2:打包完直接双击exe,鼠标转圈,然后结束,文件自动生成了
示例三:py文件名称demo.py,内容是启动tkinter界面。
打包1:D:\Python37_64\Scripts\pyinstaller -F -c demo.py
现象1:打包完直接双击exe,出现控制台,然后出现tkinter界面
打包2:D:\Python37_64\Scripts\pyinstaller -F -w demo.py
现象2:打包完直接双击exe,鼠标转圈,然后出现tkinter界面
示例四:py文件名称demo.py,内容是接收传入的两个参数,计算和。
打包1:D:\Python37_64\Scripts\pyinstaller -F -c demo.py
现象1:打开cmd 运行exe加参数,输出参数的和
打包2:D:\Python37_64\Scripts\pyinstaller -F -w demo.py
现象2:打开cmd 运行exe加参数,鼠标转圈,然后结束
备注:都合情合理,尝试了其他一些py打包,也遇到打包后运行失败的一些例子,具体解决方法还得百度,没有通用的方法。个人笔记。

浙公网安备 33010602011771号