In the previous lesson you got to know Python "by reputation"; in this one you're going to install it on your computer and get everything ready to work. By the end you'll know how to install Python 3 on Windows, macOS or Linux, check that it works, use the interactive interpreter (REPL), run your first .py scripts and work with a professional editor: Visual Studio Code. A well-configured environment from the start will save you hours of frustration; it's worth doing calmly.
Contents
- What exactly do you need?
- Installing Python 3 on Windows
- Installing Python 3 on macOS
- Installing Python 3 on Linux
- Verifying the installation
- The interactive interpreter (REPL)
- Writing and running your first
.pyscript - Installing and configuring Visual Studio Code
What exactly do you need?
To program in Python you only need two pieces:
| Piece | What it is | Example |
|---|---|---|
| The Python interpreter | The program that understands and executes Python code. | Python 3.12 (or later) |
| A code editor | Where you write your programs. A specialized editor colors the code, warns about errors and autocompletes. | Visual Studio Code |
In theory you could write Python in Notepad, but a good editor makes all the difference. In this course we'll use Visual Studio Code (VS Code): free, cross-platform and the most widely used in the community.
A note on versions: always install a recent version of Python 3 (3.10 or later). The course examples work on any modern Python 3.
Installing Python 3 on Windows
- Open your browser and go to the official website:
https://www.python.org/downloads/. - Click the yellow Download Python 3.x.x button (it will offer you the latest stable version).
- Run the downloaded installer. On the first screen, before clicking "Install Now", tick these two boxes:
- "Add python.exe to PATH" — essential. It lets you run
pythonfrom any terminal. Forgetting this box is the number one cause of problems on Windows. - "Use admin privileges when installing py.exe" (if shown).
- "Add python.exe to PATH" — essential. It lets you run
- Click Install Now and wait for it to finish.
- Close the installer.
Forgot to tick "Add to PATH"? No need to blindly reinstall: run the installer again, choose Modify, and in the advanced options enable "Add Python to environment variables". Or simply uninstall and install again with the box ticked.
On Windows there's also the option of installing Python from the Microsoft Store; it works, but the python.org installer is the more standard route and the one we'll use as our reference.
Installing Python 3 on macOS
macOS sometimes includes an old version of Python, but you shouldn't rely on it. You have two options:
Option A — Official installer (recommended to start with):
- Go to
https://www.python.org/downloads/and download the installer for macOS. - Open the downloaded
.pkgfile and follow the wizard (Continue → Agree → Install). - When it finishes, you'll have Python 3 available as
python3in the terminal.
Option B — Homebrew (if you already use this package manager):
On macOS and Linux the command is usually called python3 (with the 3), not python. Keep that in mind when following the examples.
Installing Python 3 on Linux
Most modern distributions already include Python 3. Check first (next section); if it's not there or you want to make sure you have the complete tooling:
Debian / Ubuntu / Linux Mint:
Fedora:
Arch Linux:
Verifying the installation
Open a terminal:
- Windows: search for "PowerShell" or "Command Prompt" in the Start menu.
- macOS: the Terminal application (in Applications → Utilities).
- Linux: your usual terminal emulator.
And type:
If it doesn't respond (common on macOS/Linux), try:
You should see something like:
If a version number starting with 3 appears, everything is in order. For the rest of the course we'll write python in the examples; if on your system the command is python3, use it interchangeably.
| System | Usual command |
|---|---|
| Windows | python (or py) |
| macOS | python3 |
| Linux | python3 |
The interactive interpreter (REPL)
Python ships with a fantastic tool for learning: the REPL (Read-Eval-Print Loop). It's a conversation with Python: you type an instruction, it executes it and shows you the result immediately.
To enter it, simply type in the terminal:
You'll see something like this:
Python 3.12.4 (main, Jun 8 2026, 12:00:00)
Type "help", "copyright", "credits" or "license" for more information.
>>>That >>> is the prompt: Python awaits your commands. Try a few:
>>> print("Welcome to Papyrus")
Welcome to Papyrus
>>> 15.90 + 12.50
28.4
>>> "Papyrus " * 3
'Papyrus Papyrus Papyrus'Notice three details:
- The first instruction uses
print()to display a greeting, as in the previous lesson. - The second shows that the REPL works as a calculator: we've added the prices of two of the shop's books and Python responds with the result without needing
print(). - The third reveals something curious: multiplying a text by 3 repeats it three times. The REPL is perfect for making this kind of experiment without fear.
To exit the REPL, type exit() and press Enter (or press Ctrl+Z followed by Enter on Windows, Ctrl+D on macOS/Linux).
flowchart LR
A["You type an instruction\n(Read)"] --> B["Python executes it\n(Eval)"]
B --> C["It shows the result\n(Print)"]
C --> A
The REPL is ideal for trying small things, but what you type in it is lost when you close it. To keep programs we need files.
Writing and running your first .py script
A script is a text file with the .py extension that contains Python code. Let's create the first one for the Papyrus project:
- Create a folder for the course, for example
papyrus(in your documents folder or wherever you prefer). - Inside it, create a text file called
welcome.pywith this content:
# welcome.py - First script of the Papyrus project
print("=================================")
print(" PAPYRUS - Neighbourhood bookshop")
print("=================================")
print("Management system under construction...")- Open a terminal, move into the folder with
cdand run it:
The result:
=================================
PAPYRUS - Neighbourhood bookshop
=================================
Management system under construction...Key points:
- The line starting with
#is a comment: Python ignores it. (We'll look at them in detail in the next lesson.) python welcome.pytells the interpreter: "run this file from top to bottom".- Unlike the REPL, the script is saved and you can run it as many times as you like.
| REPL | .py script |
|---|---|
| Interactive, immediate result | Runs from start to finish |
| Ideal for experimenting and trying ideas | Ideal for programs you want to keep |
| Lost when the session closes | Saved on disk |
| Shows results automatically | Only shows what you pass to print() |
Installing and configuring Visual Studio Code
Writing scripts with Notepad is possible, but uncomfortable. Let's install a real editor:
Installation
- Go to
https://code.visualstudio.com/and download the version for your operating system. - Install it with the default options (on Windows, it's useful to tick "Add to PATH" and the "Open with Code" context-menu options).
The Python extension
VS Code is a generic editor; for it to fully understand Python you need to add the official extension:
- Open VS Code.
- Click the Extensions icon in the left sidebar (or
Ctrl+Shift+X/Cmd+Shift+X). - Search for "Python" and install the extension published by Microsoft (it's usually the first one, with millions of downloads). Pylance, its autocompletion companion, will be installed too.
With the extension active you get:
- Syntax highlighting: keywords, texts and numbers in different colors.
- Autocompletion: VS Code suggests names as you type.
- Error detection: it underlines obvious mistakes in red before you run.
- Run button: a triangle ▷ at the top right runs the current file without leaving the editor.
Recommended workflow
- In VS Code: File → Open Folder... and select your
papyrusfolder. Working "by folders" (not file by file) is the professional habit. - Create or open
welcome.py. - Run it with the ▷ button or open the integrated terminal (Terminal → New Terminal, or
Ctrl+`) and typepython welcome.py.
VS Code's integrated terminal is a normal terminal embedded in the editor: everything you've learned in this lesson works the same inside it.
Common Mistakes and Tips
pythonis not recognized as a command (Windows): almost always the "Add python.exe to PATH" box wasn't ticked. Reinstall or modify the installation as explained above, and open a new terminal afterwards (already-open ones don't pick up the change).- On macOS/Linux,
pythonopens Python 2 or doesn't exist: usepython3. That's the standard name on those systems. - Saving the script as
welcome.py.txt: Windows Notepad sneakily appends.txt. Use VS Code to create your files and you'll avoid the problem. - Running
python welcome.pyfrom the wrong folder: the terminal must be in the folder where the file lives (usecdto move around, anddiron Windows orlson macOS/Linux to list the contents and check the file is there). - Writing code in the REPL expecting it to be saved: the REPL is ephemeral. Anything you want to keep goes in a
.pyfile. - Tip: spend five minutes exploring the REPL as a calculator. Losing the fear of "trying things out" is one of a programmer's most valuable skills.
Exercises
Exercise 1
Install Python on your system and verify the installation. Note down: (a) the command you used to verify it and (b) the exact version you have installed.
Exercise 2
Open the REPL and, without leaving it:
- Display the text
Papyrus opens its doorsusingprint(). - Calculate how much three of the shop's books costing
12.50,18.90and9.95would cost together. - Exit the REPL properly.
Exercise 3
In your papyrus folder, create a script called initial_catalog.py that displays the shop's name and three titles from its catalog (for example The Odyssey, Don Quixote and Hamlet), one per line, and run it from the terminal (or from VS Code).
Solutions
Solution 1
(or python3 --version on macOS/Linux). The output should be something like Python 3.12.4. Any version 3.10 or later is suitable for the course.
Solution 2
>>> print("Papyrus opens its doors")
Papyrus opens its doors
>>> 12.50 + 18.90 + 9.95
41.35
>>> exit()In step 2 you don't need print(): the REPL automatically shows the result of each expression. To exit, Ctrl+Z + Enter (Windows) or Ctrl+D (macOS/Linux) also work.
Solution 3
Content of initial_catalog.py:
# initial_catalog.py - First books in the Papyrus catalog
print("Papyrus catalog")
print("The Odyssey")
print("Don Quixote")
print("Hamlet")Running it:
Conclusion
You now have a complete development environment: Python 3 installed and verified, basic fluency with the REPL for experimenting, the ability to run .py scripts from the terminal and VS Code configured with the Python extension for comfortable work. On top of that, Papyrus already has its first welcome script and an initial catalog on screen.
From now on you'll run all the course code yourself. In the next lesson, Python Syntax and Basic Data Types, we'll start programming for real: indentation, comments, numbers, texts, booleans and the operators to combine them.
Python Programming Course
Module 1: Introduction to Python
- Introduction to Python
- Setting Up the Development Environment
- Python Syntax and Basic Data Types
- Variables and Constants
- Basic Input and Output
- Virtual Environments and Package Management
Module 2: Control Structures
Module 3: Functions and Modules
- Defining Functions
- Function Arguments
- Lambda Functions
- Modules and Packages
- Standard Library Overview
Module 4: Data Structures
Module 5: Object-Oriented Programming
Module 6: File Handling
Module 7: Error and Exception Handling
- Introduction to Exceptions
- Handling Exceptions
- Raising Exceptions
- Custom Exceptions
- Best Practices and Error Logging
Module 8: Advanced Topics
- Type Hints
- Decorators
- Generators
- Context Managers
- Concurrency: Threads and Processes
- Asyncio for Asynchronous Programming
Module 9: Testing and Debugging
- Introduction to Testing
- Unit Testing with unittest
- Testing with pytest
- Test-Driven Development
- Debugging Techniques
- Using pdb for Debugging
Module 10: Web Development with Python
- Introduction to Web Development
- Flask Framework Fundamentals
- Building REST APIs with Flask
- Introduction to Django
- Building Web Applications with Django
Module 11: Data Science with Python
- Introduction to Data Science
- NumPy for Numerical Computing
- Pandas for Data Manipulation
- Matplotlib for Data Visualization
- Introduction to Machine Learning with scikit-learn
