pyinstaller 打包python程序

准备:

  • Python 3.7 
  • PC 运行 Python 环境
  • 安装 pytistaller

命令:

  • 语法: pyinstaller [options] script [script ..] | specfile

  • pyinstaller hello.py

用参数:

  -n  文件名

  -D   创建一个可执行文件的单文件包 

  -F           创建一个绑定的可执行文件

  -w    使用窗口 无控制台

  可以通过 pyinstaller -h 或者 pyinstaller --hrlp 查看全部参数!!

开始打包:

  在要打包的python文件下 执行

        pyinstaller -F -i 静态文件\静态文件资源 python文件名.py

实战:

  

 1 # 创建py文件   test.py
 2 
 3 def hello():
 4     info_a = input('请输入a:')
 5     info_b = input('请输入b:')
 6     info = info_a + info_b
 7     print(info)
 8     return '结果为:' + info
 9 
10 
11 if __name__ == '__main__':
12     while True:# 加入无限循环可以阻止闪退
13         hello()
14 
15 
16 #打包
17 
18 pyinstaller -F test.py
19 
20 
21 #添加图标打包
22 
23 pyinstaller -F -i w1.ico test.py
View Code

end............

猜你喜欢

转载自www.cnblogs.com/xiaolizikj/p/11781030.html