首先安装pyinstaller:

pip install pyinstaller

只需要一条命令搞定:

python pyinstaller.py --console --onefile --icon="1.ico" -w 1.py