1、搭建环境

pip install pyinstaller

2、准备测试代码

exe_test.py

import time
print("hello")
print("hello")
print("hello")
print("hello")
time.sleep(5)

注:添加sleep以便在执行exe文件的时候能看到结果

3、生成exe文件

(1)命令行进入exe_test.py所在的目录

(2)生成exe文件

pyinstaller -F exe_test.py

4、获取exe文件

在dist目录中会生成exe_test.exe文件

5、自定义exe文件的版本信息参数

以上是不带版本信息参数生成exe文件

如果要