使用pyinstaller

安装命令:

pip install pyinstaller

或者

pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz

推荐使用第二种:

因为我刚开始用第一种方法安装的,然后在生成exe文件的时候出现了错误(如果出现这个错误,删除旧版本使用第二条语句安装即可)

Python:程序生成Windows可执行文件/不显示命令执行窗口/无法生成exe报错TypeError: an integer is required (got type bytes)解决方法_可执行程序

安装完成后,直接pyinstaller a.py即可

如果想去掉可执行程序打开后的dos窗口,可以使用以下命令生成exe文件

pyinstaller a.py --noconsole