Python is one of the most popular programming languages used worldwide for web development, data science, machine learning, and automation. To start coding in Python, the first step is to install it on your system. In this guide, we will walk you through the process of installing Python on Windows, Mac, and Linux. This step-by-step tutorial includes code examples to ensure you can run Python smoothly on your machine.

1. Check if Python is Already Installed
Before installing Python, it’s a good idea to check whether it is already installed. Many Mac and Linux systems come with Python pre-installed.
python --version
Or, in some cases, you may need to use:
python3 --version
If Python is installed, you will see the version number. Otherwise, you’ll need to proceed with installation.
2. Installing Python on Windows
Step 1: Download Python
Go to the official Python website: python.org/downloads and download the latest stable release for Windows.
Step 2: Run the Installer
Open the downloaded installer file. Be sure to check the option “Add Python to PATH” before clicking Install Now.
Step 3: Verify Installation
After installation, open Command Prompt and type:
python --version
This should display the installed Python version.
Example: Running a Simple Python Script on Windows
Create a new file called hello.py
with the following content:
print("Hello, Python on Windows!")
Run the file in Command Prompt:
python hello.py
You should see the output:
Hello, Python on Windows!
3. Installing Python on Mac
Step 1: Using Homebrew
Homebrew is a popular package manager for macOS. If you don’t have Homebrew installed, first run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install Python with Homebrew
brew install python
Step 3: Verify Installation
python3 --version
Now you can run Python scripts easily on Mac.
Example: Running Python on Mac
print("Hello, Python on Mac!")
Save this file as hello.py
and run:
python3 hello.py
4. Installing Python on Linux
Most Linux distributions come with Python pre-installed. However, you can still install or upgrade Python using your package manager.
Step 1: Update Package List
sudo apt update
Step 2: Install Python
sudo apt install python3
Step 3: Verify Installation
python3 --version
Example: Running Python on Linux
print("Hello, Python on Linux!")
Save the file as hello.py
and execute:
python3 hello.py
The output should be:
Hello, Python on Linux!
5. Installing pip (Python Package Manager)
pip allows you to install additional Python packages such as Flask, Django, NumPy, and Pandas. In many installations, pip is already included. To check:
pip --version
If pip is not installed, run:
- Windows: Download get-pip.py and run
python get-pip.py
. - Mac/Linux:
sudo apt install python3-pip
6. Testing pip with Example
Install the popular requests
library:
pip install requests
Create a new file test_requests.py
:
import requests response = requests.get("https://www.python.org") print("Status Code:", response.status_code)
Run it:
python test_requests.py
If successful, it will print the status code of the request, usually 200
.
Conclusion
Now you have successfully learned how to install Python on Windows, Mac, and Linux. You also know how to verify the installation, run a Python script, and install additional packages with pip. Python is extremely versatile, and installing it correctly is the first step to becoming proficient in programming. Whether you are building web apps, automating tasks, or diving into data science, Python installation is the foundation of your journey.
For more details, you can also visit the official Python documentation: Python Docs.