Maintenance

Site is under maintenance — quizzes are still available.

Go to quizzes

Install Python on Any OS

Step-by-step guide to install Python on Windows, macOS, and Linux. Includes troubleshooting and next lesson.

Focus: install python on windows, macos, and linux

Sponsored

Nothing halts a beginner’s momentum faster than a 'python' is not recognized error — or worse, installing the wrong version and fighting silent bugs. Every operating system has its quirks, yet the one thing every developer needs is a clean, reproducible Python environment. This lesson walks you through installing Python on Windows, macOS, and Linux, verifying the installation, and choosing the setup that matches your workflow.

The problem this lesson solves

Imagine you’ve just typed your first Python program — print("Hello, World!") — and your terminal spits back command not found. Frustrating, right? Even after installing Python, you might land on an outdated version, fail to add it to your system PATH, or accidentally use Python 2 instead of Python 3. Without a reliable install, you cannot follow tutorials, run scripts, or set up a virtual environment.

This lesson eliminates the guesswork. By the end, you will have Python 3.10 or later running on your machine, know how to verify the version, and understand why certain installation choices matter for professional development.

Core concept / mental model

Think of Python as a double-engine jet: the interpreter (the engine that runs code) and the package manager (pip, the fuel line that delivers extra parts). Installing Python is like securing those two components on your specific runway — Windows, macOS, or Linux — and making sure the control tower (PATH) knows where to find them.

Key definitions

  • Interpreter (python3 or python): Executes .py files line by line.
  • Package manager (pip): Installs third-party libraries like requests or numpy.
  • Environment variable PATH: The operating system’s phonebook – when you type python, the system looks through directories listed in PATH to find the executable.

Pro tip: Always install the latest stable Python 3 release (not Python 2, which reached end of life in 2020). Check python.org/downloads for the current version.

How it works step by step

The installation process follows the same three stages on every OS:

  1. Download the installer from python.org or a package manager.
  2. Run the installer with OS-specific settings (e.g., “Add Python to PATH” on Windows).
  3. Verify via the terminal that the interpreter and pip are accessible.

Windows step-by-step

  1. Go to python.org/downloads/windows and click the Download Python 3.x.x button.
  2. Run the .exe installer. Crucially, check the box “Add Python to PATH” at the bottom of the first screen.
  3. Click Install Now — the default location (C:\Users\YourName\AppData\Local\Programs\Python\Python3xx) is fine.
  4. Open Command Prompt or PowerShell and run:
python --version
pip --version

macOS step-by-step

  1. Download the macOS 64-bit universal2 installer from python.org/downloads/mac-osx.
  2. Mount the .dmg file and run the .pkg installer. Follow the prompts — no special options needed.
  3. Open Terminal and type:
python3 --version
pip3 --version

Note: macOS may pre‑install Python 2. Always use python3 and pip3 to isolate the new version.

Linux step-by-step

Most distributions include Python 3, but it may be old. Use your package manager to install or upgrade:

# Ubuntu / Debian
sudo apt update
sudo apt install python3 python3-pip -y

# Fedora / RHEL
sudo dnf install python3 python3-pip

# Verify
python3 --version
pip3 --version

Hands-on walkthrough

Let’s build a small test to confirm everything works. Create a file called hello.py with the following content:

# hello.py
import sys

print("Current Python version:")
print(sys.version)
print("\nAll good! You're ready to code.")

Run it in your terminal:

python hello.py        # Windows
python3 hello.py       # macOS / Linux

Expected output (your version numbers will differ):

Current Python version:
3.11.5 (main, Sep 11 2023, 08:19:27) [Clang 16.0.0 (clang-1600.0.26.4)]

All good! You're ready to code.

Now test that pip is available and can install a small library:

pip install requests              # Windows
pip3 install requests             # macOS / Linux

Write a quick script to make a web request:

# test_requests.py
import requests
response = requests.get('https://api.github.com')
print(f"Status code: {response.status_code}")

Run it:

python test_requests.py

Expected output: Status code: 200

Compare options / when to choose what

Installation method Pros Cons Best for
Official installer from python.org Most up‑to‑date, full control Manual updates Windows & macOS production setups
Package manager (apt, dnf, brew) Automatic updates, integrates with system May lag behind latest release Linux, advanced macOS users (Homebrew)
pyenv Multiple Python versions side by side Steeper learning curve Developers needing 2.7 vs 3.x for legacy projects
Microsoft Store (Windows only) Simple, adds to PATH automatically Can be behind latest version, limited customisation Beginners on Windows who want a single click

Pro tip: For this track, the official installer or system package manager is the most straightforward. Save pyenv for later when you need to manage multiple projects with different Python versions.

Troubleshooting & edge cases

  • 'python' is not recognized on Windows: The PATH environment variable does not include Python. Re‑run the installer and ensure “Add Python to PATH” is checked. Restart your terminal.
  • python vs python3 on macOS/Linux: Use python3 explicitly. If python fails, check python3 --version.
  • pip command not found: On some Linux distros, install pip separately: sudo apt install python3-pip.
  • Multiple Python versions: If you see Python 2.7, you likely also have Python 3. Run python3 --version. Use alias python=python3 (temporary) or update your system’s default symlink (advanced).
  • Permission errors on Linux/macOS: Use sudo for system-wide installs, or consider a virtual environment later.
  • 32-bit vs 64-bit: Always download the 64-bit installer unless you are on very old hardware.

What you learned & what's next

You can now install Python on Windows, macOS, and Linux with confidence. You understand: - The difference between the interpreter and pip. - How to verify your Python version (python --version / python3 --version). - How to install packages with pip. - Which installation method fits your use case.

This foundation unlocks the next lesson: Setting Up a Virtual Environment. Virtual environments let you isolate project dependencies — a non‑negotiable skill for real‑world Python development. If you skipped the official installer or used a package manager, you are perfectly positioned to move forward.

Final check: Open a new terminal and run python --version (or python3 --version). You should see Python 3.10.x or higher.

Practice recap

Open a terminal and create a file test.py containing print("Installation successful!"). Run it with python test.py (Windows) or python3 test.py (macOS/Linux). If you see the message, you are ready for the next lesson on virtual environments.

Common mistakes

  • Checking 'Add Python to PATH' after installation has finished — you must check it before clicking Install Now. Re-run the installer if missed.
  • Using python instead of python3 on macOS/Linux. The system often has Python 2.7 pre-installed; python3 points to the modern version.
  • Installing the 32-bit version on 64-bit hardware — always download the 64-bit installer unless you are on an old machine.
  • Skipping the pip verification step. Even if Python is installed, pip may be missing, especially on Linux (sudo apt install python3-pip).

Variations

  1. Use pyenv to manage multiple Python versions on one system and switch between them per project.
  2. Use the Microsoft Store app for a one-click install on Windows (less control, but includes PATH setup).
  3. Install via Homebrew on macOS (brew install python@3) for easy updates and integration with other development tools.

Real-world use cases

  • Setting up a local development environment for a Django web application ensures you use the correct Python version for the project.
  • CI/CD pipelines (GitHub Actions, GitLab CI) require a clean Python installation to run tests in identical OS environments.
  • Data science workflows (Jupyter Notebook, pandas) depend on a correct Python 3 installation with the SciPy stack installed via pip.

Key takeaways

  • Always install the latest stable Python 3 (≥ 3.10) from python.org or your system package manager.
  • On Windows, check 'Add Python to PATH' during installation to avoid command not found errors.
  • Use python3 and pip3 explicitly on macOS/Linux, as python may point to Python 2.
  • Verify both python --version and pip --version in a new terminal after installation.
  • Choose the official installer for full control, or a package manager for automatic updates.

Sponsored

Sponsored

Discussion

Questions, corrections, and tips help everyone reading this page.

0 comments

Add a comment

Shown publicly with your comment.

Be constructive · max 4,000 characters

No comments yet — start the thread.

Related tutorials, quizzes, and articles for this topic.