python利用pyinstaller打包常用打包命令


 

將需要打包的程序放到一個新文件夾里,在文件夾圖標上 shift +鼠標右鍵,然后選擇Open PowerShell window here,

接着輸入你想要的打包命令,如下:

pyinstaller指令的常見可選參數:

可選參數 格式舉例
功能說明
-F pyinstaller -F demo.py 只在dist中生產一個demo.exe文件
-D pyinstaller -D demo.py 默認選項,除了demo.exe外,還會在在dist中生成很多依賴文件,推薦使用
-c pyinstaller -c demo.py 默認選項,只對windows有效,使用控制台,就像編譯運行C程序后的黑色彈窗
-w pyinstaller -w demo.py 只對windows有效,不使用控制台
-p pyinstaller -p E:\python\Lib\site-packages demo.py 設置導入路徑,一般用不到
-i pyinstaller -i D:\file.icon demo.py 將file.icon設置為exe文件的圖標

上面的可選參數可以組合使用,比如pyinstaller -F -i D:\file.icon demo.py

能夠 from xxx import yyy就盡量不要 import xxx,這樣可以減少打包后的體積。



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM