1、安裝py2app
首先安裝一個(gè)gui框架wxpython
安裝:pipinstallpy2app
2、打包app
比如一個(gè)簡(jiǎn)單的gui,hello.py
!/usr/bin/envpython
importwx
app=wx.App(False)#Createanewapp,don'tredirectstdout/stderrtoawindow.
frame=wx.Frame(None,wx.ID_ANY,"HelloWorld")#AFrameisatop-levelwindow.
frame.Show(True)#Showtheframe.
app.MainLoop()
生成setup文件:
py2applet--make-setuphello.py
打包:
pythonsetup.pypy2app-A
生成文件:
雙擊可以運(yùn)行了。
以上內(nèi)容為大家介紹了python如何打包成app?希望對(duì)大家有所幫助,如果想要了解更多Python相關(guān)知識(shí),請(qǐng)關(guān)注IT培訓(xùn)機(jī)構(gòu):千鋒教育。