python程式打包成exe(使用pyinstaller)

來源:互聯網
上載者:User

標籤:

pyinstaller:https://github.com/pyinstaller/pyinstaller/

(這個檔案能夠自動安裝依賴項,其他版本的貌似還要自己安裝依賴項)

下載之後解壓到某個檔案夾內,1所示為解壓後的檔案

              圖1-解壓後pyinstaller檔案夾

 

解壓完成後會在檔案夾內看到setup.py檔案

從cmd進入檔案目錄,》

install setup.py

 

會提示載入……然後自動連網的情況下會自動下載依賴檔案pywin32以及pywin32的依賴檔案……

最後提示安裝成功,這個時候就可以使用了……

D:\pyinstaller\pyinstaller-develop>python pyinstaller.py --console --onefile  wdf.py

D:\pyinstaller\pyinstaller-develop是進入的pyinstaller檔案目錄

wdf.py是我要打包的檔案,就直接放在pyinstaller.py同一個檔案夾內了。

運行完成後,在當下檔案夾裡出現一個wdf檔案夾

上面編譯出來的exe能夠正常運行了,但帶一個黑色的console,以下重新編譯,加入--windowed --icon,取消--console   

D:\pyinstaller\pyinstaller-develop>python pyinstaller.py  -w  --onefile --icon="my.ico" wdf.py  

icon是表徵圖檔案,py為要打包的程式。最後產生一個wdf.exe可執行檔,點擊wdf.exe可以顯示繪製的圖形。

python程式打包成exe(使用pyinstaller)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.