使用Pyinstaller对Python文件打包

1.安装Pyinstaller

pip install pyinstaller

2.对Python文件打包

pyinstaller.exe -F  xxx.py    #-F  Create a one-file bundled executable

3.将文件一起打包到Python程序中

Python中使用

import os
path1=os.path.abspath('..') # 当前文件夹 filePath=path1+"\\LRSetting.bat" os.system(filePath)

xxx.spec 中修改

pathex=['C:\\Users\\Test\\Desktop\\3DMark'],
binaries=[('.\\LRSetting.bat','LRSetting')],

打包命令

pyinstaller -F xxx.spec

猜你喜欢

转载自www.cnblogs.com/jyang/p/11690364.html