Python Tutorials

How to Install Python on Windows, Linux, and Mac

Before we can start writing incredible scripts, automating tasks, or building web applications, we need to invite Python into our computer.

Computers don’t natively understand Python code out of the box. They only understand binary (1s and 0s). To bridge this gap, we need to install the Python Interpreter—a special piece of software that reads your human-friendly Python code and translates it into instructions your computer can actually execute. Think of it as hiring a translator so you can communicate seamlessly with your machine.

Prerequisites

Before we begin the installation, make sure you have the following ready:

  • A computer running a modern operating system (Windows 10/11, macOS, or a Linux distribution).
  • An active internet connection to download the official installation files.
  • Administrator (or root) privileges on your computer, as installing software requires permission to modify system files.

Step-by-Step Installation Guide

The installation process differs slightly depending on your operating system. Follow the instructions for the machine you are currently using.

🍎 Installing Python on macOS

macOS historically came with a very old version of Python pre-installed, but it is highly recommended to install the latest official version to ensure you have all modern features.

  1. Download the Installer: Open your web browser and navigate to the official Python website at python.org/downloads. The website will automatically detect that you are using a Mac and suggest the latest version. Click the Download Python button.
  2. Run the Installer: Once the .pkg file is downloaded, double-click it to open the installation wizard.
  3. Follow the Prompts: Click “Continue” through the Introduction, Read Me, and License screens. Agree to the software license agreement.
  4. Install: Click Install and enter your Mac’s administrator password when prompted.
  5. Install Certificates: [Insert Screenshot of macOS Python folder here] Once finished, a Finder window will open. Double-click the file named Install Certificates.command. This is a crucial step that ensures your Python programs can securely connect to the internet!

🪟 Installing Python on Windows

Windows does not come with Python pre-installed. The process is straightforward, but there is one critical checkbox you must not miss!

  1. Download the Installer: Go to python.org/downloads. The site will detect Windows. Click the large yellow Download Python button.
  2. Launch the Installer: Open the .exe file you just downloaded.
  3. CRITICAL STEP – Add to PATH: At the very bottom of the installer window, you will see a checkbox labeled Add Python.exe to PATH. You MUST check this box. [Insert Screenshot of 'Add Python to PATH' checkbox here]. If you miss this, your computer won’t know where to find Python later!
  4. Install Now: Click Install Now at the top of the window. Allow the app to make changes to your device if prompted by Windows User Account Control.
  5. Disable Path Length Limit (Optional but Recommended): At the end of a successful installation, you may see an option to “Disable path length limit.” Click it to prevent future issues with long file names, then close the installer.

🐧 Installing Python on Linux (Ubuntu/Debian)

Most Linux distributions actually come with Python pre-installed! However, you should ensure you have the latest python3 version using your package manager.

  1. Open the Terminal: Use the shortcut Ctrl + Alt + T.
  2. Update Package Lists: Type the following command and press Enter (provide your password if asked): sudo apt update
  3. Install Python 3: Type the following command and press Enter: sudo apt install python3 python3-pip
  4. This will install both the Python interpreter and pip, which is Python’s official tool for downloading third-party add-ons later.

Verifying the Setup

Let’s test if our “translator” is officially hired and working! We will do this by opening your computer’s Terminal (macOS/Linux) or Command Prompt (Windows).

  1. Open your command line interface:
    • Windows: Press the Start button, type cmd, and press Enter.
    • macOS: Press Cmd + Space, type Terminal, and press Enter.
    • Linux: Open your Terminal app.
  2. Check the version: Type python --version (or python3 --version on Mac/Linux) and press Enter.
  3. If installed correctly, you will see the version number printed back to you, like Python 3.12.x.

Now, let’s write a tiny, genuine Python script to prove the interpreter is working perfectly.

# Create a variable with a descriptive name to hold our success message
installation_status = "Congratulations! Python is successfully installed."

# Print the message to the screen
print(installation_status)

# Expected Output:
# Congratulations! Python is successfully installed.
Code language: PHP (php)

Common Errors & Troubleshooting

Even with a step-by-step guide, things can occasionally go wrong. Here are the most common beginner roadblocks:

  • Error: 'python' is not recognized as an internal or external command... (Windows)
    • The Fix: You forgot to check the Add Python to PATH box during installation. Don’t worry! Just re-run the installer you downloaded, choose “Modify”, and make sure the box for adding Python to environment variables/PATH is checked.
  • Error: Typing python opens the Microsoft Store (Windows)
    • The Fix: Windows is trying to be helpful but is getting in the way. Go to your Windows Search bar, type Manage app execution aliases, and open the settings menu. Scroll down and turn OFF the switches next to python.exe and python3.exe.
  • Error: Command not found: python (macOS/Linux)
    • The Fix: On Mac and Linux, Python 3 often requires you to explicitly type python3 instead of just python when running commands in the terminal. Try typing python3 --version.

Summary

  • You need to install the Python Interpreter so your computer can read and execute Python code.
  • On macOS, download the official installer and remember to run the Install Certificates.command file afterward.
  • On Windows, you absolutely must check the “Add Python to PATH” box during the installation wizard.
  • On Linux, use your built-in package manager (apt) to download Python and pip.
  • You can verify your installation anytime by opening your terminal or command prompt and running python --version or python3 --version.

You now have a fully functional Python environment on your computer! Next, we will look at how to choose the right software to actually write our code comfortably.

Leave a Comment