python入门指南(一)python 项目打包

 

在Administrator|当前,目录下

1.spec文件生成   

pyi-makespec -w xxx.py

2、配置图片,配置文件依赖

#打开cmd运行窗口

console=True

#配置文件等,需要用文件绝对路径

datas=[('C:\\Users\\Administrator\\Desktop\\\xa3\xc1\xa3\xd4\\linhuajian\\auto-test\\src\\interface.conf','.'),('C:\\Users\\Administrator\\Desktop\\\xa3\xc1\xa3\xd4\\linhuajian\\auto-test\\src\\result.xml','.'),('C:\\Users\\Administrator\\Desktop\\\xa3\xc1\xa3\xd4\\linhuajian\\auto-test\\src\\chen.jpg','.')],

 

 

3、pyinstaller    xxx.spec(报告目录引用 需用绝对路径)

#结果

在dist目录下生成exe

4、避免打包闪退

import sys
try:
put all your code here
except:
print "Unexpected error:", sys.exc_info() # sys.exc_info()返回出错信息
raw_input('press enter key to exit') #这儿放一个等待输入是为了不让程序退出

参考博文:https://blog.csdn.net/weixin_42052836/article/details/82315118

                  https://yujunjiex.gitee.io/2018/10/18/PyInstaller%E6%89%93%E5%8C%85%E8%AF%A6%E8%A7%A3/

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值