码迷,mamicode.com
首页 > 编程语言 > 详细

pyinstaller 打包python程序

时间:2019-11-02 12:18:14      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:color   options   strong   end   file   窗口   view   test   play   

准备:

  • 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............

pyinstaller 打包python程序

标签:color   options   strong   end   file   窗口   view   test   play   

原文地址:https://www.cnblogs.com/xiaolizikj/p/11781030.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!