Python – PyInstaller UAC does not work in single-file mode

PyInstaller UAC does not work in single-file mode… here is a solution to the problem.

PyInstaller UAC does not work in single-file mode

Hello everyone.

I have a small Python project and want to turn it into a single executable. I’m using….

  • Windows 7
  • python 3.4
  • PyInstaller 3.2.1

My PyInstaller command is

PyInstaller -y -w -F -n output_file_name --uac-admin --clean source_file.py

This command works correctly. However, individual output files do not require administrator privileges when executed. And there is no shielding mark on the executable file icon.

When the -F option (equivalent to –onefile) is removed, the output executable has a shield mark on its icon and asks me for admin privileges. But that’s not what I want. I want an executable.

I found a list file (output_file_name.exe.manifest) in the dist\output_file_name folder. So I did….

PyInstaller -y -w -F -n output_file_name --manifest output_file_name.exe.manifest --uac-admin --clean source_file.py

But this command does not work. Its individual executable still does not require administrator privileges.

I have removed PyInstaller and installed the latest development version.

pip install git+https://github.com/pyinstaller/pyinstaller.git@develop

But the result is the same. Its output has no shield marks on the icon and does not require administrator privileges.

Do you have any ideas?

Please help me!

Solution

I found the problem!

The point is….

  1. Install PyInstaller 3.0
  2. The list file must be in the same dist folder as the individual executable
  3. The name of the

  4. list file must be the same as the name of the output file.
  5. If the list file is in the dist folder, you do not need to specify the –manifest option. –uac-admin is sufficient.
  6. You can find the list file in the build folder.

Thank you.

Related Problems and Solutions