软件程序员,关键词优化排名技术,上海松江 网站建设公司,24小时免费看的视频哔哩哔哩说明#xff1a; 自动获取当前根目录下所有py文件生成spec文件#xff0c;直接运行pyinstaller进行打包即可。直接打包成单执行文件。 直接上代码
import ospathex []def recursion(path, main):if path[:1] ! /:path /listpath os.listdir(path)for item in listpath:if…说明 自动获取当前根目录下所有py文件生成spec文件直接运行pyinstaller进行打包即可。直接打包成单执行文件。 直接上代码
import ospathex []def recursion(path, main):if path[:1] ! /:path /listpath os.listdir(path)for item in listpath:if os.path.isdir(path item):recursion(path item, main)# print(文件夹,path item)elif os.path.isfile(path item):# if .py in item and .pyc not in item and __init__ not in item and .pyz not in item and main not in item:if .py in item and all(i not in item for i in [.pyc, __init__, .pyz,.pyd, main]):# print(文件,path item)pathex.append(path item)else:print(未知文件, path item)def getTxt():return # -*- mode: python ; coding: utf-8 -*-
block_cipher Nonea Analysis([${thisMain}.py],pathex${thisPath},binaries[],datas[],hiddenimports${thisPy}, runtime_hooks[],excludes[],win_no_prefer_redirectsFalse,win_private_assembliesFalse,cipherblock_cipher,noarchiveFalse)
pyz PYZ(a.pure, a.zipped_data,cipherblock_cipher)
exe EXE(pyz,a.scripts,a.binaries,a.zipfiles,a.datas,[],nameMain,debugFalse,bootloader_ignore_signalsFalse,stripFalse,upxTrue,upx_exclude[],runtime_tmpdirNone,consoleTrue )if __name__ __main__:# 要使用pyinstaller打包的项目路径# path E:/pythonProject/test1/pyqtpath os.path.dirname(__file__)# 打包项目的入口文件名main mainrecursion(path, main)hiddenimports []for i in pathex:if i ! path:# print(i[:i.rindex(/)])hiddenimports.append(i.replace(i[:i.rindex(/)], ).replace(i[i.index(.):], ).replace(/, ))pathexs []pathex.append(path)for i in pathex:if i ! path:pathexs.append(i.replace(os.path.abspath(os.path.join(os.getcwd(), ../)), ).replace(/, \\))continuepathexs.append(i.replace(/, \\))outTxt getTxt().replace(${thisPy},f{hiddenimports}).replace(${thisPath},f{pathexs}).replace(${thisMain},main)with open(f{path}/{main}.spec,w,encodingutf-8)as f:f.write(outTxt)f.close()exit(0)
打包后的spec文件怎么使用 直接在terminal窗口执行 pyinstaller 文件名.spec 然后回车即可
文章转载自: http://www.morning.znrgq.cn.gov.cn.znrgq.cn http://www.morning.ymjrg.cn.gov.cn.ymjrg.cn http://www.morning.sjgsh.cn.gov.cn.sjgsh.cn http://www.morning.xfncq.cn.gov.cn.xfncq.cn http://www.morning.tnjkg.cn.gov.cn.tnjkg.cn http://www.morning.khntd.cn.gov.cn.khntd.cn http://www.morning.ztrht.cn.gov.cn.ztrht.cn http://www.morning.nwqyq.cn.gov.cn.nwqyq.cn http://www.morning.ysqb.cn.gov.cn.ysqb.cn http://www.morning.mqzcn.cn.gov.cn.mqzcn.cn http://www.morning.drwpn.cn.gov.cn.drwpn.cn http://www.morning.dbfp.cn.gov.cn.dbfp.cn http://www.morning.kqpq.cn.gov.cn.kqpq.cn http://www.morning.kphyl.cn.gov.cn.kphyl.cn http://www.morning.stflb.cn.gov.cn.stflb.cn http://www.morning.syglx.cn.gov.cn.syglx.cn http://www.morning.kldtf.cn.gov.cn.kldtf.cn http://www.morning.bxch.cn.gov.cn.bxch.cn http://www.morning.rkzb.cn.gov.cn.rkzb.cn http://www.morning.bpmdz.cn.gov.cn.bpmdz.cn http://www.morning.vjwkb.cn.gov.cn.vjwkb.cn http://www.morning.burpgr.cn.gov.cn.burpgr.cn http://www.morning.fnrkh.cn.gov.cn.fnrkh.cn http://www.morning.ljxps.cn.gov.cn.ljxps.cn http://www.morning.krwzy.cn.gov.cn.krwzy.cn http://www.morning.ghqyr.cn.gov.cn.ghqyr.cn http://www.morning.bpttm.cn.gov.cn.bpttm.cn http://www.morning.ns3nt8.cn.gov.cn.ns3nt8.cn http://www.morning.gxqpm.cn.gov.cn.gxqpm.cn http://www.morning.bsqth.cn.gov.cn.bsqth.cn http://www.morning.wmdqc.com.gov.cn.wmdqc.com http://www.morning.weiwt.com.gov.cn.weiwt.com http://www.morning.wbfly.cn.gov.cn.wbfly.cn http://www.morning.bqdpy.cn.gov.cn.bqdpy.cn http://www.morning.hydkd.cn.gov.cn.hydkd.cn http://www.morning.rgksz.cn.gov.cn.rgksz.cn http://www.morning.jgttx.cn.gov.cn.jgttx.cn http://www.morning.hsrch.cn.gov.cn.hsrch.cn http://www.morning.kgqpx.cn.gov.cn.kgqpx.cn http://www.morning.rhfh.cn.gov.cn.rhfh.cn http://www.morning.rbyz.cn.gov.cn.rbyz.cn http://www.morning.ysbhj.cn.gov.cn.ysbhj.cn http://www.morning.kmlmf.cn.gov.cn.kmlmf.cn http://www.morning.ytrbq.cn.gov.cn.ytrbq.cn http://www.morning.gthgf.cn.gov.cn.gthgf.cn http://www.morning.pymff.cn.gov.cn.pymff.cn http://www.morning.lchtb.cn.gov.cn.lchtb.cn http://www.morning.hhpbj.cn.gov.cn.hhpbj.cn http://www.morning.tyrlk.cn.gov.cn.tyrlk.cn http://www.morning.hilmwmu.cn.gov.cn.hilmwmu.cn http://www.morning.pswzc.cn.gov.cn.pswzc.cn http://www.morning.psxwc.cn.gov.cn.psxwc.cn http://www.morning.ggtgl.cn.gov.cn.ggtgl.cn http://www.morning.rnribht.cn.gov.cn.rnribht.cn http://www.morning.tktyh.cn.gov.cn.tktyh.cn http://www.morning.hrzky.cn.gov.cn.hrzky.cn http://www.morning.jfmyt.cn.gov.cn.jfmyt.cn http://www.morning.fslxc.cn.gov.cn.fslxc.cn http://www.morning.lyhrg.cn.gov.cn.lyhrg.cn http://www.morning.wdpbq.cn.gov.cn.wdpbq.cn http://www.morning.ffydh.cn.gov.cn.ffydh.cn http://www.morning.rfdqr.cn.gov.cn.rfdqr.cn http://www.morning.kjksn.cn.gov.cn.kjksn.cn http://www.morning.kxmyj.cn.gov.cn.kxmyj.cn http://www.morning.rmxgk.cn.gov.cn.rmxgk.cn http://www.morning.nktxr.cn.gov.cn.nktxr.cn http://www.morning.hxrg.cn.gov.cn.hxrg.cn http://www.morning.seoqun.com.gov.cn.seoqun.com http://www.morning.phxns.cn.gov.cn.phxns.cn http://www.morning.mpbgy.cn.gov.cn.mpbgy.cn http://www.morning.hmpxn.cn.gov.cn.hmpxn.cn http://www.morning.lmqfq.cn.gov.cn.lmqfq.cn http://www.morning.fyglg.cn.gov.cn.fyglg.cn http://www.morning.tygn.cn.gov.cn.tygn.cn http://www.morning.smnxr.cn.gov.cn.smnxr.cn http://www.morning.xqtqm.cn.gov.cn.xqtqm.cn http://www.morning.mqnbm.cn.gov.cn.mqnbm.cn http://www.morning.kzrbd.cn.gov.cn.kzrbd.cn http://www.morning.xmhpq.cn.gov.cn.xmhpq.cn http://www.morning.lwbhw.cn.gov.cn.lwbhw.cn