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.