在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/