我們都知道,python檔案必須要安裝python,那么有沒有一種方法使其可以獨立運行呢?下面讓我們了解一下
準備
- 安裝pyinstaller
不會下載的點這里
pip install pyinstaller下載慢的點這里
pip install pyinstaller -i http://mirrors.aliyun.com/pypi/simple/ - 將[python安裝目錄]\Scripts添加到Path
不會添加的點這里
按下Win+R并輸入"C:\Windows\System32\control.exe system" 打開"高級系統設定" 選擇"高級"選項卡,并打開"環境變數..." win7/更早版本在"Path"中需要在前面加一個";" - 安裝setup factory
沒正版的點這里
下載:http://y.downya.com/down2/setupfactory_v9.1.0_downyi.com.zip 激活碼:SUF-BMDP-F2NS-GN82-FS3J - 要獨立運行的python檔案
示例
查看用法
pyinstaller <file> [-F | -D] [-c | -w] [-p <lib_path>] [-i <icon_path>]
| 引數名 | 是否必選/必選條件 | 描述 |
| file | ?? | python檔案的 cmd/powershell的相對路徑 或 絕對路徑 |
| -F | ? | 只生成單個exe格式檔案,建議小型程式使用此方式(與-D相反) |
| -D | ? | 創建一個目錄,包含exe檔案以及大量依賴檔案(默認,與-F相反) |
| -c | ? | 喚醒cmd視窗來運行程式(默認,與-w相反) |
| -w | ? | 直接運行程式,不喚醒cmd視窗(與-c相反) |
| -p | ? | 在lib_path下查找庫檔案 |
| lib_path | 指定-p時 | 指定在哪里查找庫檔案 |
| -i | ? | 指定是否使用自定義程式圖示 |
| icon_path | 指定-i時 | 指定程式圖示的 cmd/powershell的相對路徑 或 絕對路徑 |
pyinstaller test.py
pyinstaller test.py -F
pyinstaller test.py -w
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/393231.html
標籤:其他
