離線Offline Python & PyInstaller For Windows XP
離線環境+Windows xp+不同語系OS, 順便測試不同的系統語言是否會影響程式執行(簡易版)
最近作者遇到離線的環境,在無法變更系統OS的情況下,需要使用舊版OS
其中包含日文與中文OS測試(中文OS就不說明了)
流程:
Windows 10開發並封裝.exe->WindowsXP使用.exe執行
*其實可以直接全部安裝在Windows XP上,但作者的VSCode不支援~~
為此記錄了建置流程,供參考~~
如果你可以連線,不想看文章,直接看小總結:
pip==19.1.1
setuptools == 43.0.0
PyInstaller == 3.4
即可在windows xp執行
若有離線需求,請看完文章,前方坑多
1.Windows XP環境
基於版權,本次僅提供環境版本,若有OS需求,請自行準備~~
Japan日文環境:
Windows XP Professional 2002 Service Pack 3



2.Windows 10/XP 的Python環境(離線Offline)
這裡有一個坑!
因為作者的環境都是離線的,因此安裝PyInstaller前,建議先安裝其他的套件
再加上會使用到Wheel來安裝,因此建議按造排序來安裝
python-3.4.4 URL
套件版本
1.優先安裝套件,否則有機會報錯
Must Install
pip==19.1.1
setuptools == 43.0.0
wheel == 0.33.6
For PyInstaller
altgraph == 0.17
future == 0.18.2
future-fstrings == 1.2.0
macholib == 1.14
pefile == 2019.4.18
tokenize-rt == 3.0.1
pywin32-ctypes == 0.2.0
Myself dev pkg
PyYAML == 5.2
pymcprotocol == 0.3.0
Pillow == 5.4.1
*tkinter通常與python綁定,因此不需要安裝(For Python UI)
2.最後安裝的套件(很重要!!)
PyInstaller == 3.4
# PyInstaller因為離線,因此需要解壓縮手動安裝
# 在檔案PyInstaller-3.4根目錄下:
python setup.py build
python setup.py install




3. 編譯.exe並執行測試
pyinstaller 指令 說明文件
簡單說明幾個常用指令
-n NAME 或 --name NAME ->輸出檔名,預設為py檔名
-F 或 --onefile -> 封裝成.exe
-i 或 =--icon -> .exe的icon圖案
-w 或 --windowed 或 --noconsole -> 執行時,隱藏cmd畫面
# 接下來打包我們要封裝的程式後,執行
pyinstaller -F test.py
# 最後會輸出三個資料夾,我們只需要dist裡面的exe即可!!
*這邊也有個坑!
如果有需要全部重新打包,拋棄一些設定,要刪除.spec
因為預設會讀取.spec



Comments ()