py2exe 打包成執行檔
安裝
pip install cx_Freeze
執行
- 建立專案資料夾,例如test,以下均在專案資料夾中儲存/執行!
- 撰寫python程式檔(例如test.py)
- 撰寫setup.py
- 點「開始」,輸入cmd
- cd Desktop/test
- python setup.py bdist_msi
- cd dist
- 內部msi就是安裝檔
setup.py範例一
from cx_Freeze import setup, Executable
pyfile = "test.py"
base = None
options = {
'build_exe': {
'packages':[],
'include_files': []
},
}
setup(
name = "hello",
options = options,
version = "1.0",
description = 'my first exe',
executables = [Executable(pyfile, base=base)],
)
範例二 - 圖形化程式
from cx_Freeze import setup, Executable
pyfile = "GUI1.py"
base = "Win32GUI"
options = {
'build_exe': {
'packages':[],
},
}
setup(
name = "hello",
options = options,
version = "1.0",
description = '猜大小遊戲',
executables = [Executable(pyfile, base=base)]
)
補充說明
參考資料