Installing Python on Windows does not always require downloading installers from a browser. If you prefer a fast, scriptable, and clean approach, you can install Python directly using Command Prompt (CMD) with the help of Chocolatey, a popular Windows package manager.
This method is especially useful for developers who want to automate setups or avoid manual installation steps.
Chocolatey is a package manager for Windows that works similarly to apt on Linux or brew on macOS. It allows you to install, update, and manage software directly from the command line.
Benefits include:
No manual downloading
Easy updates
Works entirely from CMD
Ideal for development environments
Before installing Chocolatey, you must run CMD with administrator privileges.
Press Win + R
Type cmd
Press Ctrl + Shift + Enter to run as Administrator
But if you run inside the Windows Sandbox, you don't need to run as Administrator (I tested this)
Run the following command in CMD to download and install Chocolatey:
@"%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"Once completed, Chocolatey will be available system-wide.
You can verify the installation by running:
choco --versionWith Chocolatey installed, installing Python becomes extremely simple. Just run:
choco install -y python3The -y flag automatically confirms all prompts, making the installation fully unattended.
Chocolatey will download Python, install it, and configure the environment variables for you.
To confirm that Python was installed successfully, check the version:
Note: Quit and open the cmd window so it can identify the Python just installed.
python --versionIf Python is correctly installed, you will see output similar to:
Python 3.x.xUsing Chocolatey to install Python through Command Prompt is one of the fastest and cleanest methods on Windows. It eliminates the need for manual installers and is perfect for developers who want full control from the command line.
If you frequently set up new machines or work in automated environments, this approach will save you a lot of time.
install-python.bat
@echo off
echo ================================
echo Installing Chocolatey...
echo ================================
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"Set-ExecutionPolicy Bypass -Scope Process -Force; ^
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; ^
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
echo ================================
echo Installing Python 3...
echo ================================
choco install -y python3
echo ================================
echo Verifying Python installation...
echo ================================
python --version
echo ================================
echo Python installation done.
echo ================================
Stack Overflow: https://stackoverflow.com/a/54501315