How to Install Python on Windows, macOS, and Linux
Python is a powerful and versatile programming language used in web development, data science, automation, and more. Whether you're a beginner or a professional, installing Python on your system is the first step. This guide will walk you through the installation process for Windows, macOS, and Linux.
What You’ll Need
Before you begin, ensure you have:
- An active internet connection
- Administrative access to your computer
- Basic knowledge of your operating system
Installing Python on Windows
Follow these steps to install Python on a Windows computer:
- Visit the official Python website: python.org/downloads
- Click on Download Python for Windows. Choose the latest version.
- Run the downloaded installer.
- On the first screen, check the box that says Add Python to PATH.
- Click Install Now and wait for the installation to complete.
- Once installed, open the Command Prompt and type:
python --version
- You should see the installed Python version displayed.
Installing Python on macOS
macOS usually comes with Python pre-installed, but it’s often an older version. Here’s how to install the latest version:
- Open the Terminal application.
- Install Homebrew (if not already installed) by running:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Once Homebrew is installed, install Python using:
brew install python
- Check the Python version to verify the installation:
python3 --version
Installing Python on Linux
Most Linux distributions come with Python pre-installed. If you want to install or update it, follow these steps:
For Debian/Ubuntu-based systems:
- Open the terminal.
- Update your package list:
sudo apt update
- Install Python 3:
sudo apt install python3
- Check the version:
python3 --version
For Fedora/RHEL/CentOS:
- Open the terminal.
- Install Python using:
sudo dnf install python3
- Verify the installation:
python3 --version
Setting Up pip (Python Package Installer)
Most installations come with pip pre-installed. You can verify it by typing:
pip3 --versionIf it’s not installed, you can install it using:
sudo apt install python3-pip(for Ubuntu)
brew install pip3(for macOS)
Running Python
To start using Python, open your terminal or command prompt and type:
python3This will launch the Python interactive shell where you can type and run Python code.
Verifying Your Setup
Create a simple Python file to confirm everything is working:
# hello.py
print("Hello, Python!")
Run it using:
python hello.py(or
python3 hello.py on macOS/Linux)


No comments:
Post a Comment