將Python程序打包為exe文件,需要使用到的工具是pyinstaller
pyinstaller是一個多平台的Python程序打包為exe的免費工具
安裝pyinstaller:
1,在Windows中,pyinstaller依賴PyWin32,pypiwin32(Linux,mac忽略)
如果在安裝pyinstaller時使用的是pip或者easy_install會自動pypwin32,只需要手動安裝Pywin32即可
安裝命令:pip install pywin32
2,使用pip安裝pyinstaller
安裝命令:pip install PyInstaller
如果安裝環境沒有網絡不能使用pip安裝,可以去官網http://www.pyinstaller.org/ ,下載安裝。
注意:手動安裝需要安裝pypiwin32
3,pyinstaller的使用
打包命令:pyinstaller -F py文件路徑
打包成功后dist文件夾下就是exe了
提示:-i 可以替換默認ico圖標
命令:pyinstaller -F -i ico圖片路徑 py文件路徑