So today I’m going to show you how you can install Python using your windows command prompts I’ll be giving you some command lines command that you can use to install the Python the latest version it will automatically download install Python on your system not only this I will also show you how you can add the location of Python into your system variables so that you can access Python from any folder or directory you may want.
To install Python via the command line, follow these steps based on your operating system:
Windows
- Open Command Prompt as Administrator.
- Run the following command to download and install Python:
winget install Python.Python
- Once installed, verify by checking the version:
python --version
Alternative Method (Using Chocolatey) If you have Chocolatey installed, run:
choco install python -y
macOS
- Open Terminal.
- Install Python using Homebrew:
brew install python
- Verify installation:
python3 --version
Linux (Debian/Ubuntu)
-
Open Terminal.
- Run:
sudo apt update sudo apt install python3 -y
- Verify installation:
python3 --version
Linux (CentOS/RHEL)
- Open Terminal.
- Run:
sudo yum install python3 -y
- Verify installation:
python3 --version
Let me know if you need additional help! 🚀
IN CASE YOU DO NOT WANT TO INSTALL ANY ABOVE EXTERNAL PLUGINS YOU CAN SIMPLE USE WINDOWS POWERSHEEL TO INTALL PYTHON ON YOUR SYSTEM. THERE ARE TWO METHODS AND COMMANDS I WRITE HERE.
Method 1: Using PowerShell (Official Installer)
-
Open PowerShell as Administrator.
- Run the following command to download and install Python:
Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.12.2/python-3.12.2-amd64.exe" -OutFile "python-installer.exe"; Start-Process -FilePath "python-installer.exe" -ArgumentList "/quiet InstallAllUsers=1 PrependPath=1" -Wait; Remove-Item "python-installer.exe"
- Once the installation is complete, check if Python is installed:
python --version
Method 2: Using Chocolatey (If Installed)
If you have Chocolatey installed, you can use:
choco install python -y
If you don’t have Chocolatey, install it first using:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Method 3: Manually Adding Winget
If you still want to use Winget, check if it’s available:
- Press
Win + R
, typecmd
, and run:where winget
- If it doesn’t show a path, update your App Installer from the Microsoft Store:
Download Winget (App Installer) - Restart your PC and try running
winget
again.
Let me know which method works for you! 🚀
It looks like Winget (Windows Package Manager) is not installed or not available in your system’s environment variables. Here are some alternative ways to install Python via the command line:
If Python is installed but not recognized in the command prompt you need to add it to the system environment variables manually Here’s how:
Method 1: Add Python to PATH via Command Line
- Open Command Prompt as Administrator.
- Run the following command to check where Python is installed:
where python
If it’s not found, locate Python manually. By default, Python is installed in:
C:\Users\YourUsername\AppData\Local\Programs\Python\PythonXX
or
C:\PythonXX
- Add Python to the PATH using:
setx PATH "%PATH%;C:\Users\YourUsername\AppData\Local\Programs\Python\PythonXX"
Replace
PythonXX
with the actual folder name (e.g.,Python312
for Python 3.12). - Add the Scripts folder (for pip and other tools):
setx PATH "%PATH%;C:\Users\YourUsername\AppData\Local\Programs\Python\PythonXX\Scripts"
- Restart your Command Prompt and verify:
python --version
Method 2: Add Python to PATH via GUI
-
Press
Win + R
, typesysdm.cpl
, and press Enter. - Go to the Advanced tab and click Environment Variables.
- Under System Variables, find Path and click Edit.
- Click New, then add the Python installation paths:
C:\Users\YourUsername\AppData\Local\Programs\Python\PythonXX
C:\Users\YourUsername\AppData\Local\Programs\Python\PythonXX\Scripts
- Click OK on all windows and restart your PC.
- Open Command Prompt and check:
python --version
Let me know if you need more help! 🚀