How to Install Python on Linux, Windows, and Mac

Raj KumarRaj Kumar
4 min read

Python is one of the most popular programming languages today, widely used for web development, data science, automation, and artificial intelligence. To get started with Python, you first need to install it on your computer. In this guide, we will walk you through the step-by-step process of installing Python on Linux, Windows, and macOS. Whether you're a beginner or an experienced coder, this guide will ensure a smooth installation experience.

Why Install Python?

Before diving into the installation process, let's quickly understand why Python is essential:

  • Easy to Learn – Python has a simple syntax similar to English, making it beginner-friendly.

  • Versatile – It is used for web development, automation, AI, and more.

  • Cross-Platform – Python runs on multiple operating systems, including Linux, Windows, and Mac.

  • Strong Community Support – Thousands of libraries and frameworks make development easier.

Now, let’s explore how to install Python on different operating systems.


Installing Python on Linux

Most Linux distributions come with Python pre-installed. However, it may not be the latest version. Follow these steps to install or upgrade Python on your Linux system.

Step 1: Check if Python is Installed

Open the terminal and type:

python3 --version

If Python is installed, it will display the version number. If not, proceed with the installation.

Step 2: Install Python Using Package Manager

For Debian-based distributions (Ubuntu, Debian, etc.):

sudo apt update
sudo apt install python3

For Red Hat-based distributions (Fedora, CentOS, etc.):

sudo dnf install python3

For Arch Linux:

sudo pacman -S python

Step 3: Verify Installation

Once installed, confirm Python is working by running:

python3 --version

Alternative: Install Python from Source (Latest Version)

If you need the latest version, install Python from the official source:

sudo apt install build-essential libssl-dev libffi-dev python3-dev
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.x.x/Python-3.x.x.tgz
sudo tar xzf Python-3.x.x.tgz
cd Python-3.x.x
sudo ./configure --enable-optimizations
sudo make altinstall

Replace 3.x.x with the latest Python version.


Installing Python on Windows

Step 1: Download Python

  1. Visit the official Python website: https://www.python.org/downloads/

  2. Click on "Download Python 3.x.x" (latest version).

Step 2: Run the Installer

  1. Open the downloaded .exe file.

  2. Check the box that says "Add Python to PATH" (important for command-line use).

  3. Click Install Now and wait for the installation to complete.

Step 3: Verify Installation

Open Command Prompt and type:

python --version

If Python is installed correctly, the version number will be displayed.

Pip is a package manager for Python. It usually comes pre-installed, but you can check with:

pip --version

If not installed, run:

python -m ensurepip

To set up a virtual environment:

python -m venv myenv

This keeps dependencies separate for different projects.


Installing Python on macOS

Step 1: Check if Python is Pre-installed

macOS comes with an older version of Python. To check:

python3 --version

If it's outdated, install the latest version.

Homebrew is a package manager for macOS. Install it if you haven't already:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then, install Python:

brew install python

Step 3: Verify Installation

After installation, confirm Python is working:

python3 --version

Alternative: Download from Python’s Official Website

If you prefer, you can download Python from https://www.python.org/downloads/mac-osx/ and follow the installation steps.


Common Issues and Solutions

1. Python Command Not Found

Cause: Python is not installed or not added to PATH. Solution: Reinstall Python and ensure the "Add to PATH" option is checked during installation (Windows) or manually add it to PATH (Linux/Mac).

2. Outdated Version

Cause: Older versions may not support some libraries. Solution: Upgrade Python using:

sudo apt upgrade python3  # Linux
brew upgrade python  # macOS

Download and install the latest version for Windows.

3. Pip Not Recognized

Cause: Pip is not installed or not added to PATH. Solution: Reinstall Python, or manually install pip:

python -m ensurepip --default-pip

Conclusion

Installing Python is a straightforward process on Linux, Windows, and macOS. Whether you use a package manager, a downloadable installer, or compile from source, Python’s flexibility ensures it can run smoothly on any system. With Python set up on your computer, you are now ready to explore coding, automation, web development, and more.

If you found this guide helpful, share it with others and start coding today!

0
Subscribe to my newsletter

Read articles from Raj Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Raj Kumar
Raj Kumar