Reputation: 73
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?
Upvotes: 5
Views: 20903
Reputation: 5442
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.
Upvotes: 7
Reputation: 4539
Python 2.6.1 is already in your path as demonstrated by item number 2 in your list. On number 3, you're adding Python 2.7 to your path after Python 2.6.1's entry. You need to remove Python 2.6.1 from your environment variable, or at a minimum, set it so that 2.7 is listed first.
Upvotes: 3