首先第一次打包脚本 a.py

pyinstaller -F --uac-admin a.py

然后去build目录找a/a.exe.manifest, 将其复制到a.py同级目录下, 再次运行

pyinstall -F --uac-admin -r a.exe.manifest,1 a.py

也就是在第一次打包基础上增加-r a.exe.manifest,1, 然后查看dist目录, 发现就是带有UAC的exe了。