Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my pyinstaller created executable require admin privileges?

I've written a Python program which I distribute using pyinstaller. I've been using the onefile option so far to create a standalone executable. That's been great up until now, but as the application has grown the startup time is getting a bit long. I'd also like users to install the application properly to make upgrading simpler.

I've been trying to create a single directory version of the app using pyinstaller's onedir option. However, the resulting .exe file that is created requires admin privileges to run, which the onefile version did not. The program itself doesn't need any such privileges so I assume this is something that pyinstaller is doing. How do I create an application that doesn't require admin privileges?

Additional info:

  • Python 2.6, pyinstaller v1.4
  • Application uses PyQt4 and pygame modules.
  • Trying to create executable for Windows 7.
  • Using -w pyinstaller option to create a windowless executable.
like image 699
Whatang Avatar asked Apr 02 '12 00:04

Whatang


People also ask

Why is my PyInstaller exe not working?

The most common reason a PyInstaller package fails is that PyInstaller failed to bundle a required file. Such missing files fall into a few categories: Hidden or missing imports: Sometimes PyInstaller can't detect the import of a package or library, typically because it is imported dynamically.

Does PyInstaller exe require Python?

They do not need to have Python installed at all. The output of PyInstaller is specific to the active operating system and the active version of Python. This means that to prepare a distribution for: a different OS.

Where does PyInstaller save exe?

PyInstaller generates the executable that is a bundle of your game. It puts it in the dist\ folder under your current working directory.


2 Answers

admin privileges could be asked in few cases:

A. if the executable name contains relevant keywords (like setup, install, update or patch)

B. the application requests it in it's manifest.

C. the .exe file name do not match the name in the manifest file.

if you create a .spec file for your application package, you can add

exe = EXE(
    ...
    manifest=None,
    ...
    )

and it won't ask for password, unless you rename it to setup or install.

like image 108
Ohad Cohen Avatar answered Sep 18 '22 12:09

Ohad Cohen


I have recently run into this issue, and my experience in solving it was thus:

PyInstaller with --onefile option creates a manifest file in the 'executable'. This manifest file on Windows tells the OS a few things about the application it is bundled with. One of the things it specifies, is the application name/manifest file. The format of the manifest filename is appname.exe.manifest. If your program is frozen with PyInstaller, the executable name that it stores in the manifest will be the name given to the completed EXE under the /dist folder of PyInstaller. IF you rename the EXE, the manifest file packed with it is no longer matching! Therefore, create a manifest file with the same name as the final EXE filename and run PyInstaller with the --manifest option, OR don't rename the EXE that PyInstaller creates.

When you package the PyInstaller project with the custom --manifest, the renamed program no longer requests administrator elevation.

like image 35
PenguinCoder Avatar answered Sep 18 '22 12:09

PenguinCoder