Academy / Python from Scratch / Lesson 2 of 20

Python from Scratch Lesson 2 of 20

Installation and Development Setup

8 min read

Objectives

Installation and Development Setup

In the first lesson you saw what Python is and why we'll study it, and you picked three repetitive activities you'd like to automate. Keep them handy: starting today we'll prepare the tools that, lesson by lesson, will let us turn them into real programs.

Before writing code, we need to set up the work environment. That's what we'll do together in this lesson: no new theory, just practical steps.

What we need and why

To write a Python program you need two things: a place to write code and a program that runs it.

The place to write code is the editor: a program similar to a word processor, but designed for code. With the editor we create and modify the files that hold our programs, and we keep them in a folder dedicated to the course.

The program that runs the code is the Python interpreter: it reads the contents of a Python file, instruction by instruction, and does what the code says. When we "install Python", we're installing the interpreter.

Editor, folder, and interpreter together form what we'll call the development environment: our workbench for the whole course.

Installing Python

Python is a free download from the official website: python.org. It's the safe, up-to-date source — avoid third-party download sites.

The steps vary slightly depending on your operating system:

  1. Windows — go to python.org, Downloads section, and download the installer for the latest version of Python 3. Run it and, before confirming, look carefully at the first screen: you'll see a checkbox like "Add python.exe to PATH" (in some versions "Add Python to PATH"). Check it, then continue with the installation. If you miss it, the python command might not be directly available in the terminal: you'll notice right away in the verification step below.
  2. macOS — go to python.org, Downloads section, and download the macOS installer for the latest version of Python 3. Open it and follow the wizard: there are no special checkboxes to tick.
  3. Linux — many distributions already include Python 3. Before installing anything, run the verification described in the next section: if the command answers with a version, you're already set. Otherwise, install Python 3 following your distribution's official instructions (usually through its package manager).

Checking that it works

How do we know the installation succeeded? We ask the computer directly, with a command.

Open your system's terminal:

  • Windows: open the Start menu and search for "Command Prompt" ("PowerShell" works too).
  • macOS: open "Terminal" (it's in Applications, inside Utilities).
  • Linux: open "Terminal" from the applications menu.

The terminal is a window where you give the computer instructions by typing them instead of clicking. Today's command is read-only: it asks for information and changes nothing.

On Windows, type this command and press Enter:

python --version

On macOS and Linux, type instead:

python3 --version

If Python is installed correctly, the terminal answers with a line showing the installed version. Here's how that line might look — it's an example of the terminal's reply, not a command to type, and the exact number depends on the version you downloaded:

Python 3.12.5

What matters is that the answer shows a Python 3 version: it means the installation succeeded and the terminal recognizes Python. For a smooth experience, we recommend using a recent Python 3 version obtained through the official channels described above.

If instead the terminal replies with an error — a message saying the command was not found or is not recognized — on Windows one possible cause is the PATH checkbox left unchecked during installation: run the installer again with the checkbox ticked, then try the command once more.

Setting up the workspace

The interpreter is in place. Now for the editor and the folder.

The editor. Writing code calls for a text editor designed for programming. Our suggestion is Visual Studio Code (VS Code): free, widely used, and beginner-friendly. Download it from the official site, code.visualstudio.com. It's a recommendation, not a requirement: if you prefer another code editor, the course works exactly the same way.

The folder. Everything we build will live in a single folder, so you'll never lose the course files. Create it now in your file manager (File Explorer on Windows, Finder on macOS, your distribution's file manager on Linux) and name it python-zero. Put it wherever is convenient: inside Documents is fine.

A first file. Remember the three repetitive activities you picked in Lesson 01? Time to give them a stable home: create a text file inside python-zero — for example with the editor you just installed — name it attivita-da-automatizzare.txt, and copy your list into it. We'll come back to that file during the course: it's where our project starts to take shape.

Exercise

This lesson also ends with practice. Three steps, all yours:

  1. Install Python from python.org and verify the installation with the right command for your system. Write down the version that appears: it's the confirmation that everything works.
  2. Create the python-zero folder and save attivita-da-automatizzare.txt with your three activities from Lesson 01 inside it.
  3. Open the python-zero folder with your editor and check that you can see the file you just created.

If you completed all three steps, your development environment is ready.

Summary

  • The Python interpreter is the program that runs the code we'll write: installing it is the first step.
  • Python is downloaded from python.org; on Windows, tick the "Add to PATH" checkbox during installation.
  • The terminal lets you give the computer written commands; with python --version (or python3 --version) we check that Python 3 is installed.
  • VS Code is our recommended editor, not a mandatory one.
  • The python-zero folder is the home of the whole course: the list of activities we want to automate already lives there.

Next lesson: we'll write our first Python program.