为什么我的 pyinstaller 创建的可执行文件需要管理员权限? [英] Why does my pyinstaller created executable require admin privileges?

查看:141
本文介绍了为什么我的 pyinstaller 创建的可执行文件需要管理员权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个 Python 程序,我使用 pyinstaller 分发该程序.到目前为止,我一直在使用 onefile 选项来创建一个独立的可执行文件.到目前为止,这一直很好,但随着应用程序的增长,启动时间变得有点长.我还希望用户正确安装应用程序,使升级更简单.

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.

我一直在尝试使用 pyinstaller 的 onedir 选项创建应用程序的单目录版本.但是,生成的 .exe 文件需要管理员权限才能运行,而 onefile 版本不需要.程序本身不需要任何这样的权限,所以我认为这是 pyinstaller 正在做的事情.如何创建不需要管理员权限的应用程序?

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?

附加信息:

  • Python 2.6,pyinstaller v1.4
  • 应用程序使用 PyQt4 和 pygame 模块.
  • 尝试为 Windows 7 创建可执行文件.
  • 使用 -w pyinstaller 选项创建无窗口可执行文件.

推荐答案

我最近遇到了这个问题,我解决这个问题的经验是:

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

带有 --onefile 选项的 PyInstaller 在可执行文件"中创建一个清单文件.Windows 上的这个清单文件告诉操作系统一些关于它捆绑的应用程序的信息.它指定的一件事是应用程序名称/清单文件.清单文件名的格式为 appname.exe.manifest.如果您的程序被 PyInstaller 冻结,则它存储在清单中的可执行文件名称​​将是 PyInstaller 的 /dist 文件夹下完成的 EXE 的名称.如果重命名 EXE,那么打包的清单文件将不再匹配! 因此,创建一个与最终 EXE 文件名同名的清单文件,并使用 --manifest 运行 PyInstaller 选项,或者不要重命名 PyInstaller 创建的 EXE.

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.

当您使用自定义 --manifest 打包 PyInstaller 项目时,重命名的程序不再请求管理员提升.

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

这篇关于为什么我的 pyinstaller 创建的可执行文件需要管理员权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆