Learn Without Walls
← Lesson 1 Lesson 2 of 4 Next Lesson →

Lesson 2: Installing Python

⏱️ Estimated time: 15-20 minutes

📚 Learning Objectives

By the end of this lesson, you will be able to:

Before You Begin

To write and run Python programs, you need two things installed on your computer:

  1. Python itself — the interpreter that understands and runs your code
  2. A text editor or IDE — a program where you write your code

IDE (Integrated Development Environment) is a software application that provides tools for writing, running, and debugging code all in one place. Think of it as a "workshop" for programmers, with everything you need at your fingertips.

Let's start by installing Python. The instructions vary depending on your operating system, so select yours below.

Installing Python 3

🇪🇸 Windows
🍎 Mac
🐧 Linux

Installing Python on Windows

  1. Go to python.org
    Open your web browser and navigate to https://www.python.org/downloads/
  2. Download the installer
    Click the big yellow "Download Python 3.x.x" button. The website will detect your operating system automatically.
  3. Run the installer
    Double-click the downloaded .exe file to start the installer.
  4. IMPORTANT: Check "Add Python to PATH"
    At the bottom of the first installer screen, you will see a checkbox that says "Add python.exe to PATH". Check this box! This is the most common mistake beginners make. Without it, your computer won't know where to find Python.
  5. Click "Install Now"
    The default installation settings are fine for beginners. Click "Install Now" and wait for the installation to complete.
  6. Click "Close"
    Once you see "Setup was successful", click Close.

⚠️ Most Common Mistake

Forgetting to check "Add Python to PATH" means you'll get errors when trying to run Python from the command line. If you already installed without checking it, simply uninstall Python and reinstall it with the checkbox checked.

Installing Python on Mac

Mac computers come with an older version of Python pre-installed, but we need Python 3.

  1. Go to python.org
    Open Safari (or your preferred browser) and navigate to https://www.python.org/downloads/
  2. Download the installer
    Click the "Download Python 3.x.x" button. Download the macOS installer package.
  3. Run the installer
    Open the downloaded .pkg file and follow the installation prompts. Click "Continue" through the steps and "Agree" to the license.
  4. Complete installation
    Click "Install" and enter your Mac password when prompted. Wait for the installation to finish.
  5. Verify the installation
    Open Terminal (search for "Terminal" in Spotlight, or find it in Applications > Utilities) and type: python3 --version

💡 Mac Note

On Mac, you may need to type python3 instead of python because the older Python 2 may still be linked to the python command. Throughout this course, if python doesn't work on Mac, try python3 instead.

Installing Python on Linux

Most Linux distributions come with Python 3 pre-installed. Let's check first.

  1. Open a terminal
    Press Ctrl + Alt + T or search for "Terminal" in your applications menu.
  2. Check if Python 3 is installed
    Type: python3 --version
    If you see a version number (e.g., "Python 3.10.12"), you're already set!
  3. If not installed, install via package manager
    Ubuntu/Debian:
    sudo apt update
    sudo apt install python3 python3-pip
    Fedora:
    sudo dnf install python3 python3-pip
  4. Verify the installation
    python3 --version

Verifying Your Installation

After installing, let's make sure everything works. Open your terminal (Mac/Linux) or Command Prompt (Windows):

💻 Opening the Terminal / Command Prompt

  • Windows: Press Win + R, type cmd, press Enter. Or search "Command Prompt" in the Start menu.
  • Mac: Press Cmd + Space, type "Terminal", press Enter.
  • Linux: Press Ctrl + Alt + T.

Now type the following and press Enter:

python --version
Python 3.12.1

If you see a version starting with 3 (like 3.10, 3.11, 3.12, etc.), you're all set! If you get an error on Mac or Linux, try python3 --version instead.

✍️ Try It Yourself!

Open your terminal right now and verify your Python installation. If it's not working, go back through the installation steps for your operating system.

Understanding PATH

PATH is an environment variable that tells your operating system where to look for programs. When you type python in the terminal, your computer searches the directories listed in PATH to find the Python program.

Think of PATH like a list of addresses your computer checks when you ask it to run a program. If Python's location isn't in this list, your computer won't be able to find it, even though it's installed.

🔎 Checking Your PATH (optional)

You can see where Python is installed by typing:

Windows:

where python

Mac/Linux:

which python3
/usr/local/bin/python3

This shows the exact location of the Python executable on your system.

Choosing a Text Editor or IDE

You need a place to write your Python code. While you could use basic Notepad, a proper code editor makes programming much easier with features like syntax highlighting, auto-completion, and error detection.

Recommended Options for Beginners

⭐ VS Code (Visual Studio Code)

Best overall choice. Free, lightweight, and incredibly popular. Install the Python extension for an excellent experience.

Download from code.visualstudio.com

📡 IDLE

Comes with Python! No extra installation needed. Simple and straightforward. Good for absolute beginners who want to start immediately.

Already installed with Python

🚀 Thonny

Designed for beginners. Built-in Python, simple interface, and a great debugger that shows you what's happening step by step.

Download from thonny.org

⚡ Sublime Text

Fast and clean. A sleek editor that's fast to open and easy to use. Free evaluation with occasional purchase reminders.

Download from sublimetext.com

Our Recommendation

For this course, we recommend starting with IDLE (since it comes with Python) and eventually moving to VS Code as you get more comfortable. Both are free, and you can switch between them anytime.

Opening IDLE

IDLE (Integrated Development and Learning Environment) is Python's built-in editor. Here's how to open it:

When IDLE opens, you'll see the Python Shell—an interactive window with a >>> prompt. This is the Python interpreter, which we'll explore in detail in Lesson 4.

✍️ Try It Yourself!

Open IDLE right now. You should see something like:

Python 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023)
[GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license()" for more information.
>>>

Type print("I installed Python!") at the >>> prompt and press Enter. If you see your message, congratulations—everything is working!

✅ Check Your Understanding

1. When installing Python on Windows, what critical checkbox must you check?

Answer: You must check "Add python.exe to PATH" at the bottom of the installer's first screen. Without this, your command prompt won't be able to find Python.

2. What command do you type in the terminal to check if Python is installed?

Answer: Type python --version (or python3 --version on Mac/Linux). If Python is installed correctly, it will display the version number.

3. What is PATH and why does it matter for Python?

Answer: PATH is an environment variable that tells your operating system where to look for programs. If Python's location is not in your PATH, the terminal won't be able to find and run Python when you type python.

4. What is IDLE and how do you open it?

Answer: IDLE is Python's built-in Integrated Development and Learning Environment. It comes installed with Python. You can open it by searching for "IDLE" in your operating system's application menu or Start menu.

🎯 Key Takeaways

Ready for More?

➡️ Next Lesson

In Lesson 3, you'll write your first Python program—the famous "Hello, World!" and beyond!

Start Lesson 3

📊 Module Progress

You've completed Lesson 2! Your development environment is set up and ready to go.