Python Version in PowerShell Python Version in PowerShell powershell powershell

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.

  1. 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.
  2. 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.
  3. How PowerShell chooses what to run when you type a command is explained in help about_Command_Precedence, and is:
    1. Alias
    2. Function
    3. Cmdlet
    4. 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:


I execute the powershell command line statement in python3.8,

import subprocesssubprocess.call('powershell.exe Get-WmiObject Win32_PnPSignedDriver| select DeviceName, Manufacturer, DriverVersion', shell=True)

The running result is:

'select' is not an internal or external command, nor an executable program or batch file.