Python Version in PowerShell
In PowerShell, Get-Command python | fl *
will tell you which Python executable it's finding and show you details about where it is.
- You can check Settings -> Apps and Features, or Control Panel -> Programs and Features. They will show you distinct versions of Python you installed, but that might not be enough if Python is installed as part of some other toolkit or program.
- If Python 2.7.11 is there, select it and click uninstall. If it's not there, see if you can tell what it's installed with, from the output of
Get-Command
earlier, and decide if you want to remove that. - How PowerShell chooses what to run when you type a command is explained in help about_Command_Precedence, and is:
- Alias
- Function
- Cmdlet
- Native Windows commands
At the point of "Native Windows commands", it goes to the PATH
environment variable, a semi-colon separated list of path names, which get searched in order, looking for a matching executable file.
You can see the folders with:
$Env:PATH -split ';'
And you can watch PowerShell identify what to run for 'python' with the command
Trace-Command –Name CommandDiscovery –Expression {get-command python} -PSHost
So, to make Python 2.7.13 the one to launch, you could:
- make it the only Python version available.
- move its folder to the front of the PATH list, ahead of any other version. See: What are path and other environment variables, and how can I set or use them - question on SuperUser.com
- make a batch file to launch it called python.bat in a folder in the PATH ahead of other versions.
- make an alias (in your PS Profile) named python to launch the one you want (
New-Alias -name python -Value C:\Python27\python.exe
, etc).