Python Installation Guide

This comprehensive guide will walk you through installing Python on Windows, macOS, and Linux systems. Follow the instructions for your operating system to get Python up and running.

Python Logo
Python Programming Language

Before You Begin

Windows Logo

Windows Installation

Installing Python on Windows is straightforward using the official installer from python.org.

1 Download Python
  1. Visit the official Python website: https://www.python.org/downloads/windows/
  2. Under "Stable Releases," select the latest Python 3.x version
  3. Choose either the 32-bit (x86) or 64-bit (x86-64) installer based on your system
Python Windows Download
Python Windows Download Page
2 Run the Installer
  1. Double-click the downloaded .exe file
  2. Check the box "Add Python to PATH" at the bottom
  3. Click "Install Now" (recommended for most users)
  4. Wait for the installation to complete
Python Windows Installer
Python Windows Installer Screen
3 Verify Installation
  1. Open Command Prompt (Win+R, type cmd, press Enter)
  2. Type python --version and press Enter
  3. You should see the installed Python version
C:\Users\YourName> python --version
Python 3.9.7

Alternative: Microsoft Store

Windows 10/11 users can also install Python from the Microsoft Store:

  1. Open Microsoft Store
  2. Search for "Python"
  3. Select the latest Python 3.x version
  4. Click "Get" to install
macOS Logo

macOS Installation

There are several ways to install Python on macOS. Choose the method that best suits your needs.

Method 1: Official Installer

1 Download Python
  1. Visit the official Python website: https://www.python.org/downloads/macos/
  2. Download the latest macOS 64-bit installer
2 Run the Installer
  1. Open the downloaded .pkg file
  2. Follow the installation wizard
  3. When complete, Python will be installed in /Applications
Python macOS Installer
Python macOS Installer

Method 2: Homebrew (Recommended for Developers)

1 Install Homebrew
  1. Open Terminal (Applications > Utilities > Terminal)
  2. Run the Homebrew installation command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Follow the on-screen instructions to complete the installation.

2 Install Python with Homebrew
brew install python

This will install the latest Python version and pip (Python package manager).

Verification on macOS

To verify your Python installation:

python3 --version
pip3 --version

Note: macOS comes with Python 2.7 pre-installed. Always use python3 and pip3 to ensure you're using Python 3.

Linux Logo

Linux Installation

Most Linux distributions come with Python pre-installed, but you may need to install a specific version.

Debian/Ubuntu (APT)

1 Update Package List
sudo apt update
2 Install Python
sudo apt install python3 python3-pip python3-venv

Fedora (DNF)

1 Install Python
sudo dnf install python3 python3-pip

Arch Linux (Pacman)

1 Install Python
sudo pacman -S python python-pip

Installing Specific Versions

To install a specific Python version (e.g., Python 3.8):

# Ubuntu/Debian
sudo apt install python3.8

# Fedora
sudo dnf install python3.8

# Arch Linux (via AUR)
yay -S python38

Compiling from Source

For complete control over the installation:

1 Install Dependencies
# Ubuntu/Debian
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev

# Fedora
sudo dnf install gcc openssl-devel bzip2-devel libffi-devel zlib-devel
2 Download and Compile
wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz
tar -xf Python-3.9.7.tgz
cd Python-3.9.7
./configure --enable-optimizations
make -j 8
sudo make altinstall

Replace "3.9.7" with your desired version. Use make altinstall to avoid overwriting the system Python.

Verifying Your Installation

After installation, verify that Python is working correctly on your system.

1 Check Python Version
# Windows Command Prompt
python --version

# macOS/Linux Terminal
python3 --version
2 Run Python Interpreter
# Windows
python

# macOS/Linux
python3

You should see the Python REPL with version information and the >>> prompt.

3 Run a Simple Script

Create a file called hello.py with the following content:

print("Hello, Python!")

Run it with:

# Windows
python hello.py

# macOS/Linux
python3 hello.py

Troubleshooting Common Issues

"Python is not recognized" (Windows)

If you get this error, Python is not in your PATH:

  1. Reinstall Python and check "Add Python to PATH"
  2. Or manually add Python to PATH:
    1. Search for "Environment Variables"
    2. Click "Environment Variables"
    3. Under "System variables", find "Path" and click "Edit"
    4. Add Python's installation directory (e.g., C:\Python39)
    5. Add the Scripts directory (e.g., C:\Python39\Scripts)

Multiple Python Versions

To manage multiple Python versions:

Permission Denied Errors (Linux/macOS)

If you get permission errors when installing packages:

# Avoid using sudo with pip
pip install --user package_name

# Or better, use virtual environments
python3 -m venv myenv
source myenv/bin/activate  # Linux/macOS
pip install package_name

Next Steps After Installation

Install Essential Tools

# Install pip (if not already installed)
python -m ensurepip --upgrade

# Upgrade pip
python -m pip install --upgrade pip

# Install virtualenv
pip install virtualenv

Recommended Packages

# Data science stack
pip install numpy pandas matplotlib jupyter

# Web development
pip install flask django

# Code formatting and linting
pip install black flake8

Learning Resources