Windows下自动将Python路径添加到PATH系统变量

发布于 2024-09-15 10:28:55 字数 126 浏览 0 评论 0原文

我正在创建一键式 python 安装程序(与我的应用程序集成)。有没有办法强制Python MSI安装程序将python的路径添加到SYSTEM PATH变量? 我使用 MSI 安装程序,因为它很容易指定(使用命令行)它应如何与用户交互。

I'm creating one-click python installer (integrated with my application). Is there any way to force Python MSI installer to add python's path to SYSTEM PATH variable?
I'm using MSI installer because it is very easy to specify (using command line) how it should interact with the user.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七堇年 2024-09-22 10:28:55

用户变量存储在 Windows 注册表中的 HKEY_CURRENT_USER\Environment 下,

我将在安装后脚本中使用 winreg 来设置或添加到那里的 PATH。

http://docs.python.org/library/_winreg.html

User variables are stored in the Windows Registry under HKEY_CURRENT_USER\Environment

I would use winreg in a post install script to set or add to the PATH there.

http://docs.python.org/library/_winreg.html

云淡月浅 2024-09-22 10:28:55

一定有办法,但有些人所做的就是提供批处理文件,在调用 Python 之前设置环境。不管怎样,BZR 就是这么做的。如果您可以将该批处理文件写入路径中通常已经存在的某个位置,那就更好了。

如果您只是担心调用 Python,普通的 Python 安装程序会进行文件关联,因此您可以按照这种方式进行操作。

There has to be a way, but what some people do is provide batch files that set up the environment before invoking Python. That's what BZR does, anyway. If you can write that batch file somewhere that's already normally in the path, so much the better.

If you're just worried about invoking Python, the normal Python installer does file associations, so you can work it that way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文