Windows下自动将Python路径添加到PATH系统变量
我正在创建一键式 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用户变量存储在 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
一定有办法,但有些人所做的就是提供批处理文件,在调用 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.