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:

  • 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).
Answer from TessellatingHeckler on Stack Overflow
Top answer
1 of 3
34

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:

  • 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).
2 of 3
1

This was a question about python 2.7, but probably it will be useful to give an answer for the versions above 3.3 too:

Previously, multiple versions (also environments, also they are specific folders) of python on the same system was rare, and placing the only available python.exe directly in PATH was acceptable. Currently, multiple installed python versions will conflict and override each other if simply placed that way.
After 3.3 a python launcher was introduced which detects and activates one of the installed versions automatically. It is supposed to be placed in PATH instead of any python executable.

So in this modern situation, Get-Command python | fl * may give you nothing or nothing helpful.
And to run scripts or to get available versions, use launcher:

  • ensure you have it:
    try Get-Command py command from the PowerShell. If launcher is missing, it can be installed with the official installer. There is a separate checkbox for the launcher which is enabled by default.
  • if install is correct, command py --list-paths will give a summary on the installed versions, and supposed way to run scripts is not previous python main.py, but commands like py main.py or py -3.5 main.py. Run py --help for more info.

Additional confirmation that intended way changed.

Just to give an idea, launcher is not the only way to activate, this also can be done by a simple command.
For example, there is a version under D:\python_install\python.exe. But it's not in the PATH and python command correctly ends with not found error or opens Windows Store. An additional command in cmd or bat SET PATH=D:\python_install\;%PATH% or PowerShell $env:Path = "D:\python_install\;" + $env:Path temporarily activates that specific version, and python will work as previously during that specific run.

🌐
Reddit
reddit.com › r/learnpython › 'python' not recognized in powershell
r/learnpython on Reddit: 'python' not recognized in Powershell
May 26, 2023 -

I have read through some previous posts with the same issue but the solutions are not working for me. Hoping someone can point to my error.

  1. Trying to delete Python reference in Windowsapps directory using windows explorer. I get an error message that does not let me delete them.

  2. In environmental variables I moved windows apps down below the python line. I still get an error message in Powershell that Python not found.

Discussions

PowerShell does not show output of `where python` command
Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... More on github.com
🌐 github.com
6
December 11, 2024
Running Python in PowerShell - Stack Overflow
I am attempting to learn the very basics of Python using the guide "Learn Python the Hard Way" by Zed A. Shaw. The problem that I am having is that I can run Python scripts, but only when... More on stackoverflow.com
🌐 stackoverflow.com
Command "where python" does not return anything in PowerShell - Stack Overflow
As the title implies, when I am trying to where python from PowerShell it returns nothing. No errors or something... it just goes to a new line (as if I pressed "Enter") On the other hand... More on stackoverflow.com
🌐 stackoverflow.com
I'm trying to use Python in PowerShell - Stack Overflow
I'm trying to follow Zed Shaw's guide Learning Python the Hard Way. I need to use Python in PowerShell. I have Python 2.7.3 installed in C:\Python27. Whenever I type python into a PowerShell windo... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

How can I run a Python script from PowerShell?
Use the following PowerShell command to execute a Python script: · $pythonPath = cmd /c "where python" · $scriptPath = "C:\Path\To\YourScript.py" · $argument = "your_argument" · $output = & $pythonPath $scriptPath $argument · $output · This command locates the Python executable, runs the specified script with an argument, and captures the output.
🌐
advancedinstaller.com
advancedinstaller.com › execute-python-script-through-powershell.html
Executing Python Scripts through PowerShell: A Step-by-Step Guide
How do I pass arguments from PowerShell to a Python script?
In your Python script, use the sys module to access command-line arguments: · import sys · print(f"Received argument: {sys.argv[1]}") · Then, from PowerShell, pass the argument as shown: · & python your_script.py your_argument · This will output: Received argument: your_argument.
🌐
advancedinstaller.com
advancedinstaller.com › execute-python-script-through-powershell.html
Executing Python Scripts through PowerShell: A Step-by-Step Guide
Can I integrate Python scripts into an MSI package?
Yes. In Advanced Installer, you can add a custom action to run a PowerShell script that executes your Python script. Ensure that Python is installed on the target machine or include it as a prerequisite in your installer.
🌐
advancedinstaller.com
advancedinstaller.com › execute-python-script-through-powershell.html
Executing Python Scripts through PowerShell: A Step-by-Step Guide
🌐
Python.org
discuss.python.org › python help
Why doesn't python 3.10.0 show up on PowerShell? - Python Help - Discussions on Python.org
October 12, 2021 - Greetings, all I am excited to learn python, and have enrolled in a course to this effect. However, I started encountering problems right off the mark. I installed Python 3.10.0 from the Python homepage (it defaulted to the amd64 installer for Windows) and followed all the steps - disable the 260 character limit, add python to path, etc.
🌐
Advanced Installer
advancedinstaller.com › execute-python-script-through-powershell.html
Executing Python Scripts through PowerShell: A Step-by-Step Guide
February 22, 2024 - This will return the full path(s) to the Python installation(s) on your system. Yes. In Advanced Installer, you can add a custom action to run a PowerShell script that executes your Python script.
🌐
GitHub
github.com › PowerShell › PowerShell › issues › 24662
PowerShell does not show output of `where python` command · Issue #24662 · PowerShell/PowerShell
December 11, 2024 - Refer to Differences between Windows PowerShell 5.1 and PowerShell. Run command where python on PowerShell and Command Prompt.
Author   PowerShell
🌐
Oxylabs
oxylabs.io › blog › how-to-run-python-script-in-powershell
How to Run Python Script in PowerShell
March 20, 2025 - PowerShell can handle complex automation, remote system management, and integration with other Microsoft technologies. ... To run Python scripts, you first need to have Python installed on your system.
Find elsewhere
🌐
Full Stack Python
fullstackpython.com › powershell.html
PowerShell - Full Stack Python
PowerShell is a commandline user interface for Windows that is often used as part of a Python programmer's development environment.
🌐
Jamie Phillips
phillipsj.net › posts › executing-powershell-from-python
Executing PowerShell from Python • Jamie Phillips
October 26, 2020 - You will not need any external libraries since we use one of the many great libraries that ship out of the box with Python. All we need is to create a file call ps.py, and then we can import the subprocess module. ... Now we can make our run method that we will use to execute our PowerShell command.
🌐
Microsoft Learn
learn.microsoft.com › en-us › windows › dev-environment › python
Python on Windows for beginners | Microsoft Learn
Install Python: Install Python from the Microsoft Store. The Microsoft Store version automatically configures your PATH and provides automatic updates. Once installed, open PowerShell and run python --version to verify.
🌐
Medium
medium.com › @ddasdocs › managing-python-in-system-path-using-powershell-b6a62b9ae76b
Managing Python in System PATH Using PowerShell | by dwdas | Medium
September 21, 2023 - When working with Python on Windows, ensuring it’s accessible from any terminal or command prompt is pivotal. This accessibility is achieved by including Python in the system’s PATH variable. In this guide, we’ll delve into using PowerShell to check Python’s presence in the PATH and add it if missing.
🌐
Reddit
reddit.com › r/learnpython › powershell cant run python
r/learnpython on Reddit: Powershell cant run Python
November 12, 2018 -

I am really new at all this so forgive me if I sound dumb or ignorant.I am just beginning to learn Python.Initially,I was going through Microsofts Introduction to Python on edX and I went through Module 1 but I didnt understand how to access the web coding assignment at the end.I still went through all the exercises and the MCQ's and I was doing pretty good at them so I didnt want to give up so I decided to find another way to learn. I got the pdf of Learn Python the Hard Way and decided to follow that instead.

I have already installed Atom and Python 3.6.7 and clicked add file path.But when I tried to type python in Powershell nothing comes up and I cant run anything.Its driving me crazy and I spent like an hour trying to get it to run but nothing.How can I get it to run?

Anyway,can I just follow the steps in Learn Python the Hard Way using Jupyter Notebooks instead?I went through exercise 1 in LPTHW in Jupyter and it seemed fine but in the book the author says if I cant set up then I shouldnt even continue and its stressing me out.

Again,I am really new to all of this,I am like a super beginner in Python.If anyone can help,I would be eternally so grateful to the stars and beyond.

Thanks!

EDIT:Thanks for the help everyone.I tried to set a new file path but even then I couldnt get anything in Powershell.I decided to use IDLE instead for now.Maybe over the weekend I may try to figure out whats wrong again.

🌐
Microsoft
devblogs.microsoft.com › dev blogs › powershell team › hosting powershell in a python script
Hosting PowerShell in a Python script - PowerShell Team
June 30, 2022 - The pythonnet package gives Python developers extremely easy access to the dotnet runtime from Python. I thought this package might be the key for accessing PowerShell, after some investigation I found that it has exactly what I needed to host PowerShell in a Python script.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1332563 › windows-powershell-starts-old-python
Windows powershell starts old python - Microsoft Q&A
July 18, 2023 - PS C:\Users\XXX> ftype Python.File="C:\path\to\python3.11.4\python.exe" "%1" %* After making any changes, close and reopen your PowerShell window to apply the changes.
🌐
Python.org
discuss.python.org › python help
Powershell and python executables - Python Help - Discussions on Python.org
June 5, 2023 - I’m trying to run simple python scripts with PowerShell. I can run my scripts in .cmd without a hitch. The path looks proper. I opened PowerShell in admin mode as well and it’s still not working. Researching the web, it seems that MicroSoft disables the functionality of running python with ...