LazyCodet

a

06:29:36 19/1/2026 - 0 lượt xem -
Programming

Download Python Using Only Command Prompt on Windows

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.


Why Use Chocolatey?

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


Step 1: Open Command Prompt as Administrator

Before installing Chocolatey, you must run CMD with administrator privileges.

  1. Press Win + R

  2. Type cmd

  3. 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)


Step 2: Install Chocolatey

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 --version

Step 3: Install Python 3 Using CMD

With Chocolatey installed, installing Python becomes extremely simple. Just run:

choco install -y python3

The -y flag automatically confirms all prompts, making the installation fully unattended.

Chocolatey will download Python, install it, and configure the environment variables for you.


Step 4: Verify Python Installation

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 --version

If Python is correctly installed, you will see output similar to:

Python 3.x.x

Conclusion

Using 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.

Bonus: Script install Python BAT

​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 ================================


Reference