The best way to install Python through Windows Command Prompt will be through Chocolatey (Windows Package Manageer).

Steps to install python 3 will be as follows :-

  1. Open CMD using 'Run as Administrator'.

  2. Download and Install Chocolatey using the following command.

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
  1. Download and install python using the following command.
choco install -y python3
  1. You can check the version to verify if Python was successfully installed as follows.
python --version
Answer from Cyborg on Stack Overflow
🌐
Microsoft Learn
learn.microsoft.com › en-us › windows › dev-environment › python
Python on Windows for beginners | Microsoft Learn
April 15, 2026 - 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.
Discussions

Install python with a script or powershell
Im looking for some help with an install script. We want to push out python to end users in the background via powershell or script. Has anyone had any success with it? More on discuss.python.org
🌐 discuss.python.org
1
0
January 24, 2024
Using Powershell to Install Python
Hi all A while ago I created a script in powershell to install python and it worked if I was running the script but then I automated it in Jenkins so it... More on techcommunity.microsoft.com
🌐 techcommunity.microsoft.com
2
0
February 1, 2024
Powershell script to install python and add environment variable and run python commands
Hello Experts, I am trying to automate installation of python and add environment variables and run some python commands. I was able to install python from script and was able to add environment variables, but issue is we need to close and reopen the script to run python commands. is there ... More on community.spiceworks.com
🌐 community.spiceworks.com
2
5
July 1, 2025
Installing Python with Powershell and "System" Account
Hi, I am doing my head in here. I have an installation script that works perfectly for everything through Windows Task Scheduler except Python. It uses the system account on the server to run this task. It doesn't error when installing Python, but what… More on learn.microsoft.com
🌐 learn.microsoft.com
2
0
April 2, 2023
🌐
Python
docs.python.org › 3 › using › windows.html
4. Using Python on Windows — Python 3.14.6 documentation
To install the file downloaded from python.org, either double-click and select “Install”, or run Add-AppxPackage <path to MSIX> in Windows Powershell.
🌐
Python.org
discuss.python.org › python help
Install python with a script or powershell - Python Help - Discussions on Python.org
January 24, 2024 - Im looking for some help with an install script. We want to push out python to end users in the background via powershell or script. Has anyone had any success with it?
🌐
Stevens
fsc.stevens.edu › installing-python-on-windows-11-workstations
Installing and Using Python on Windows 11 Workstations
September 4, 2025 - It is based on the most common ... to install and use Python environments. Most commands here are done through the terminal. This is to ensure reproducibility and ease of following instructions. To access the terminal on Hanlon Lab machines, search for the Terminal app. If the machine is on Windows 10, Terminal may not be available. In that case, search for PowerShell...
🌐
Microsoft Community Hub
techcommunity.microsoft.com › microsoft community hub › communities › products › powershell › windows powershell
Using Powershell to Install Python | Microsoft Community Hub
February 1, 2024 - A while ago I created a script in powershell to install python and it worked if I was running the script but then I automated it in Jenkins so it ran remotely on the machine.
Find elsewhere
🌐
DEV Community
dev.to › jajera › install-python-on-windows-via-cli-winget-3lnm
Install Python on Windows via CLI (winget) - DEV Community
September 23, 2025 - Here’s how you can install Python 3 in seconds, entirely from the terminal. Press Win + X → select Windows PowerShell (Admin) or Terminal (Admin). ... Name Id Version ---------------------------------------- Python 3.13 Python.Python.3.13 ...
🌐
Coding for Entrepreneurs
codingforentrepreneurs.com › guides › install-python-on-windows
Install Python on Windows - Coding for Entrepreneurs
Coding for Entrepreneurs · Learn · Enroll · Courses · Suggestions · Shorts · Community · Testimonials · Connect
🌐
Spiceworks
community.spiceworks.com › programming & development
Powershell script to install python and add environment variable and run python commands - Programming & Development - Spiceworks Community
July 1, 2025 - Hello Experts, I am trying to automate installation of python and add environment variables and run some python commands. I was able to install python from script and was able to add environment variables, but issue is…
🌐
Bigblue
bigblue.academy › en › how-to-download-python-for-windows-step-by-step
How to Install Python on Windows
June 25, 2023 - Winget is a package manager for Windows programs, included in Windows 11. To install Python via winget, open a terminal such as command line, PowerShell, or Windows Terminal.
🌐
GitHub
gist.github.com › Daethyra › 66c78005b8e9c8e1dc28dd9e43021596
Python 3.10.11 PowerShell Auto-Installation · GitHub
Save Daethyra/66c78005b8e9c8e1dc28dd9e43021596 to your computer and use it in GitHub Desktop. Download ZIP · Python 3.10.11 PowerShell Auto-Installation · Raw · Py31011_PSAI.ps1 · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1195583 › installing-python-with-powershell-and-system-accou
Installing Python with Powershell and "System" Account - Microsoft Q&A
April 2, 2023 - Does that installer interact with the desktop in any way? The system account has no profile, like a normal user would have, that's accessible. ... You would need to use the equivalent of msiexec's /quiet switch. Maybe I should ask: is the "Python installer" msiexec.exe?
🌐
H2S Media
how2shout.com › home › developer › 2 ways to install latest python on windows 11 or 10 – gui & cmd
2 Ways to install latest Python on Windows 11 or 10 – GUI & CMD
January 18, 2023 - Especially, for those who are not ... interpreted programming language. ... Installing Python 3 on Windows 10 or 111. Download Python’s latest version2. Start Python Installation on Windows3. Check version4. Stop Python from opening the Microsoft store5. Open PowerShell, CMD, or Terminal ...
Top answer
1 of 1
1
  • When PowerShell calls external programs (such as python-3.11.4-amd64.exe), it reports their process exit code via the automatic $LASTEXITCODE variable. By convention, external programs signal success with value 0, and failure with any nonzero exit code.

  • However, PowerShell is only able to report the exit code if the external program executes synchronously (i.e., it blocks the caller until the program terminates), whereas PowerShell executes GUI(-subsystem) applications asynchronously by default (i.e., it launches the external program and immediately returns control to the caller).

Installers such as python-3.11.4-amd64.exe are typically GUI applications, so extra effort is needed to make the call synchronous, so that your script (a) awaits completion of the installation and (b) can check for success vs. failure via $LASTEXITCODE.

There are several ways to make invocation of a GUI application synchronous.
In the case at hand - for a GUI application that also reports a meaningful exit code - the simplest solution is to pipe to Write-Output.

"About to install Python. "
# Note the `| Write-Output` at the end, which makes the invocation 
# synchronous and populates the $LASTEXITCODE variable.
c:/temp/python-3.11.4-amd64.exe /quiet InstallAllUsers=0 InstallLauncherAllUsers=0 PrependPath=1 Include_test=0 | Write-Output

# Check if the installation failed and exit, if so.
if ($LASTEXITCODE -ne 0) {
  Write-Error "Installation failed unexpectedly; exit code is $LASTEXITCODE."
  exit $LASTEXITCODE
}

See this answer for an explanation of the technique, as well as alternatives.

🌐
Hexnode
hexnode.com › mobile-device-management › help › script-to-install-python-on-windows-devices
Script to install Python on Windows devices - Hexnode Help Center
May 14, 2024 - This PowerShell script begins by defining variables for the desired Python version and its download URL. The placeholder “version” can be replaced with the specific version number needed. Subsequently, the script defines the installation directory path. Utilizing the Invoke-WebRequest cmdlet, the script downloads the Python installer from the specified URL and saves it in a temporary directory. To ensure a silent installation without any user interface or interaction, the script employs the Start-Process cmdlet with the /quiet argument.
🌐
Real Python
realpython.com › installing-python
How to Install Python on Your System: A Guide – Real Python
February 18, 2026 - After you’ve selected the Python Install Manager app, follow these steps to complete the installation: Click the Get button. Wait for the app to download. Click the Open button. When you click the Open button, you’ll be presented with a terminal window. Follow the on-screen instructions to complete the installation. Once the installation is complete, open Windows PowerShell and run the python --version command to confirm that Python is installed on your machine.
🌐
Advantech Cloud IoT Service Portal
advantech-ncg.zendesk.com › hc › en-us › articles › 4404778102669-How-to-install-python3-and-pip-on-Windows-10-11
How to install python3 and pip on Windows 10/11? – Advantech ESG Service Center
March 28, 2025 - In the search of Windows, please enter "Microsoft Store" and press "Enter" key · In the search of "Microsoft Store" and enter "python" then press "Enter" key · Click the python that you want to install. Then click the "Get" to get the preferred version of python. Stay tuned and wait for the installation progress bar completed. Close all PoweShell and re-open a new PowerShell then run the "python -V" or "python --version" to check the installed python version
🌐
Oxylabs
oxylabs.io › blog › how-to-run-python-script-in-powershell
How to Run Python Script in PowerShell
March 20, 2025 - This guide explains how to run Python scripts using the PowerShell command-line interface. It details the process of installing Python, creating a simple script, and executing it from PowerShell, enabling Python's capabilities within the Windows environment for scripting and automation.
🌐
GitHub
gist.github.com › raoshaab › de861c353ab0e0cb77f8afd5325e43c1
Install Python 3 with powershell in windows 10 · GitHub
# Define the target installation directory i.e $installDir = "D:\newfolder\python3" $installDir = "D:\Python3" # Install Python with specified installation directory Start-Process -FilePath $pythonInstaller -ArgumentList "/quiet PrependPath=1 TargetDir=$installDir" -Wait