如何设置python路径并在powershell链接,在PowerShell中为Python设置路径?

I have two Python versions on my machine (Windows Vista), 2.6 (located in C/Program files) and 2.7 (located in C/).

1- I open PowerShell

2- I type python, and it calls python 2.6.1.

3- I want to change the path for Python 2.7, so I type:

[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")

4- and then when I run python again it still calls the version 2.6. and there is no way I can change it. I also tried to restart the computer after changing the path, with no success.

Any suggestions?

解决方案

You have to set the path in the Environment Variables settings so it would be kept after closing shell and/or reboot.

Computer (right-click) > Properties > Advanced System Settings > Environment Variables

You can create a new user variable called Path, or append to the system one (so it'd affect all users).

Add your Python27 directory there in the Path system variable (with a ; as a separator). You can swap them (C:\Python26;C:\Python27 and C:\Python27;C:\Python26) to change the default one.

DXdYf.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值