Python Programming Installation Guide
Windows, macOS, Linux Package Management

Python Installation & Setup Complete Guide

Step-by-step tutorial to install Python on Windows, macOS, and Linux. Learn to set up development environment, install packages, and configure tools for Python programming.

Windows

Step-by-step guide

macOS

Homebrew & installer

Linux

Package manager

Packages

pip & virtual env

Python Installation Overview

Python installation is straightforward across all major operating systems. This guide covers Python installation for Windows, macOS, and Linux, along with setting up a proper development environment.

Quick Start

For most users: Download installer from python.org → Run installer → Check "Add Python to PATH" → Verify installation with python --version

Before You Begin
  • Check if Python is already installed
  • Download latest Python version (3.12+)
  • Choose correct installer for your OS
  • Ensure stable internet connection
  • Administrator/root access may be needed
What You'll Get
  • Python interpreter (python.exe/python3)
  • pip package manager
  • IDLE development environment
  • Python standard library
  • Documentation and examples

Python Installation on Windows

Windows users can install Python using the official installer from python.org. Follow these step-by-step instructions:

Windows Installation Steps
  1. Download Python Installer

    Visit python.org/downloads and download the latest Python 3.x installer for Windows (64-bit recommended).

  2. Run the Installer

    Double-click the downloaded .exe file. CRITICAL: Check the box "Add Python to PATH" at the bottom before clicking "Install Now".

    During Installation
    Install Python 3.x (64-bit)
    ☑ Install launcher for all users (recommended)
    ☑ Add Python 3.x to PATH  ← MUST CHECK THIS
    Click "Install Now"
  3. Verify Installation

    Open Command Prompt (cmd) and check if Python is installed correctly:

    Command Prompt
    # Check Python version
    python --version
    
    # Expected output: Python 3.x.x
    
    # Start Python interactive shell
    python
    
    # Exit Python shell
    exit()
Important: If you get "'python' is not recognized as an internal or external command", Python was not added to PATH. Reinstall Python with "Add Python to PATH" checked, or manually add Python to system PATH.

Python Installation on macOS

macOS comes with Python 2.7 pre-installed, but you should install Python 3 for modern development. Two methods available:

Method 1: Official Installer
  1. Download macOS Installer

    Download the macOS installer from python.org/downloads/macos

  2. Run Installer Package

    Open the .pkg file and follow the installation wizard. No additional configuration needed.

  3. Verify Installation

    Open Terminal and check Python 3 installation:

    Terminal
    # Check Python 3 version
    python3 --version
    
    # Start Python 3 interactive shell
    python3
    
    # Note: Use python3 (not python) command
Method 2: Homebrew (Recommended)

Homebrew is a popular package manager for macOS. Install Python using Homebrew:

Terminal Commands
# Install Homebrew (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Python 3 using Homebrew
brew install python

# Verify installation
python3 --version
Tip: Homebrew automatically adds Python to PATH and handles updates better than the official installer.

Python Installation on Linux

Most Linux distributions come with Python pre-installed, but you may need to install Python 3 or update to the latest version.

Ubuntu/Debian
Terminal Commands
# Update package list
sudo apt update

# Install Python 3
sudo apt install python3 python3-pip python3-venv

# Install additional development packages
sudo apt install python3-dev build-essential

# Verify installation
python3 --version
pip3 --version
RHEL/CentOS/Fedora
Terminal Commands
# For RHEL/CentOS
sudo yum install python3 python3-pip

# For Fedora
sudo dnf install python3 python3-pip

# Install development tools
sudo yum groupinstall 'Development Tools'
# or
sudo dnf groupinstall 'Development Tools'

# Verify installation
python3 --version
Arch Linux
Terminal Commands
# Update system
sudo pacman -Syu

# Install Python
sudo pacman -S python python-pip

# Verify installation
python --version

Installing Additional Python Modules

Python comes with pip (Package Installer for Python) to install additional packages from PyPI (Python Package Index).

Note: On Windows use pip, on macOS/Linux use pip3 or python3 -m pip

Basic pip Commands

Terminal/Command Prompt
# Install a package
pip install package-name

# Install specific version
pip install package-name==1.0.0

# Upgrade a package
pip install --upgrade package-name

# Uninstall a package
pip uninstall package-name

# List installed packages
pip list

# Show package information
pip show package-name

# Install from requirements file
pip install -r requirements.txt

Essential Python Packages

Package Command Purpose Category
numpy pip install numpy Numerical computing library Data Science
pandas pip install pandas Data manipulation and analysis Data Science
matplotlib pip install matplotlib Plotting and visualization Data Science
django pip install django Full-featured web framework Web Development
flask pip install flask Lightweight web framework Web Development
requests pip install requests HTTP library for API calls Web/API
beautifulsoup4 pip install beautifulsoup4 Web scraping library Web Scraping
scikit-learn pip install scikit-learn Machine learning library AI/ML
tensorflow pip install tensorflow Deep learning framework AI/ML
jupyter pip install jupyter Interactive notebook environment Development

Virtual Environments (Best Practice)

Always use virtual environments to manage project dependencies:

Creating Virtual Environment
# Create virtual environment
python -m venv myenv

# On Windows: Activate
myenv\Scripts\activate

# On macOS/Linux: Activate
source myenv/bin/activate

# Install packages in virtual environment
pip install numpy pandas

# Deactivate virtual environment
deactivate

# Create requirements.txt
pip freeze > requirements.txt

# Install from requirements.txt
pip install -r requirements.txt

Verifying Your Installation

After installation, verify everything is working correctly:

Verification Script
# verification.py
import sys
import platform

print("Python Installation Verification")
print("=" * 40)
print(f"Python Version: {sys.version}")
print(f"Platform: {platform.platform()}")
print(f"Python Executable: {sys.executable}")

# Check essential imports
try:
    import numpy
    print("✓ NumPy installed")
except ImportError:
    print("✗ NumPy not installed")

try:
    import pandas
    print("✓ pandas installed")
except ImportError:
    print("✗ pandas not installed")

print("\nRun this script with: python verification.py")
Success Checklist:
  • ✓ Python installed and accessible from terminal
  • ✓ pip package manager working
  • ✓ Can create and activate virtual environments
  • ✓ Can install and import packages

Troubleshooting Common Issues

Common Problems
  • "python not found" - Add Python to PATH
  • Permission denied - Use sudo (Linux/macOS)
  • pip not working - Reinstall Python
  • SSL certificate error - Update pip: python -m pip install --upgrade pip
  • Outdated Python - Download latest version
Useful Commands
  • Check Python path: where python (Windows) / which python3 (macOS/Linux)
  • Update pip: python -m pip install --upgrade pip
  • Clear pip cache: pip cache purge
  • Install specific Python version: Use pyenv
  • Check environment variables: echo %PATH% (Windows) / echo $PATH (macOS/Linux)

Installation Key Points

  • Always download Python from official website: python.org
  • Check "Add Python to PATH" during Windows installation
  • Use virtual environments for project isolation
  • Regularly update pip: python -m pip install --upgrade pip
  • Use requirements.txt for dependency management
  • Verify installation with python --version and pip --version
  • For production, use specific Python versions and lock dependencies
Next Topics: Learn Python Syntax Basics including variables, data types, and basic operations