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:
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.
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.
PyInstaller generates the executable that is a bundle of your game. It puts it in the dist\ folder under your current working directory.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With