#Python3#打包成exe
2018-12-04 本文已影响32人
AlanSS
1.安装pyinstaller
PyInstaller Quickstart
Install PyInstaller from PyPI:
pip install pyinstaller
Go to your program’s directory and run:
pyinstaller yourprogram.py
This will generate the bundle in a subdirectory called dist.
2.打包成一个exe文件
pyinstaller yourprogram.py这个命令是基础的打包命令,会将py文件打包成依赖多个dll文件的exe文件。
想要打包成单一的exe文件需要用到下面的命令:
pyinstaller --onefile yourprogram.py
中间位置可以用到的参数如下表:

修改exe的图标:
pyinstaller --onefile --icon=C:\ico\icon.ico yourprogram.py
(其中C:\ico\icon.ico为图标地址)