Lesson 2: Installing Python and Setting Up the Environment
·Programming

Lesson 2: Installing Python and Setting Up the Environment

A step-by-step guide to installing Python and setting up your coding environment correctly.

Lesson 2: Installing Python and Setting Up the Environment

Now that you know what programming is, it's time to build your workshop. To write and run Python code, you need two things: the Python Interpreter (the engine) and a Code Editor (the workspace).

Lesson Overview

In this lesson, we will:

  • Install Python: Getting the engine running on your computer.
  • Verify the Installation: Making sure everything is set up correctly.
  • Set Up VS Code: Installing the world's most popular code editor.
  • Install the Python Extension: Giving your editor "superpowers."

Step 1: Installing Python

Python is free and works on Windows, macOS, and Linux.

For Windows Users:

  1. Go to python.org/downloads.
  2. Click the big button that says "Download Python 3.x.x".
  3. IMPORTANT: When the installer starts, check the box that says "Add Python to PATH". If you miss this, your computer won't know where Python is!
  4. Click "Install Now."

For macOS Users:

  1. Go to python.org/downloads.
  2. Download the macOS installer.
  3. Open the .pkg file and follow the instructions.

Step 2: Verifying the Installation

Let's make sure Python is actually there. We do this using the Terminal (macOS/Linux) or Command Prompt (Windows).

  1. Open your Terminal or Command Prompt.
  2. Type the following command and press Enter:
python --version

(Note: On some Macs, you might need to type python3 --version instead.)

Expected Output: You should see something like Python 3.12.1. If you see a version number, you're ready to go!


Step 3: Setting Up Your Code Editor (VS Code)

While you can write code in a simple text editor like Notepad, professionals use an IDE (Integrated Development Environment). We recommend Visual Studio Code (VS Code) because it's clean, fast, and great for beginners.

  1. Go to code.visualstudio.com.
  2. Download and install the version for your OS.
  3. Open VS Code once it's installed.

Step 4: Adding Python Superpowers to VS Code

VS Code is a general tool. We need to tell it we’re working with Python.

  1. On the left sidebar of VS Code, click the Extensions icon (looks like four squares).
  2. Search for "Python".
  3. Find the one made by Microsoft and click Install.

This extension gives you features like:

  • Intellisense: Predicting what you’re going to type.
  • Linting: Highlighting errors as you write them.
  • Integrated Debugging: Helping you find mistakes later.

How it All Fits Together

Think of it like this:

  • Python: The language/engine.
  • Your Code: The instructions you write.
  • VS Code: The paper and pen you use to write those instructions.
  • The Terminal: Where you see the instructions being carried out.

Practice Exercise

  1. Check your Python version in the terminal.
  2. Open VS Code and install the Python extension.
  3. Take a screenshot of your VS Code workspace once the extension is installed.

Quick Knowledge Check

  1. What is the most important box to check when installing Python on Windows?
  2. What command do you use to check if Python is installed?
  3. What is VS Code used for?
  4. Why do we need the Python extension in VS Code?

Key Takeaways

  • The Python Interpreter is required to run code.
  • Checking "Add to PATH" is crucial on Windows.
  • VS Code is a powerful and beginner-friendly code editor.
  • The Python extension makes VS Code a specialized Python workshop.

What’s Next?

With your environment ready, it’s time to actually write some code! In Lesson 3, we will create our first project and learn how to run it inside VS Code.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn