0.2 Installing Python and an editor¶
Suggested time: 1 lesson · Syllabus: 0478 4.2.5 (the IDE) · 9618 12.3 (finding and correcting errors)
What you will do¶
Install Python, choose an editor, and run your first program. By the end of this chapter you will be able to:
- explain what an interpreter and an IDE are;
- install Python, or check that it is already installed;
- choose between Thonny, VS Code and IDLE;
- write, save and run a program.
Key vocabulary¶
| Term | Meaning | Example |
|---|---|---|
| Python | The programming language, and the program that runs it | Python 3.14 |
| Interpreter | A program that reads your code and carries it out, one statement at a time | python3, py |
| IDE | Integrated Development Environment: an editor with tools for running and debugging code | Thonny, VS Code, IDLE |
| Script | A saved Python program | hello.py |
| Console / shell pane | The part of the IDE where your program's output and error messages appear | Thonny's Shell pane |
The big idea: an editor and an interpreter¶
You need two things to program in Python:
- an interpreter, the program that runs Python code;
- an editor to write the code in.
An IDE puts both together, with a Run button, a console for output and error messages, and usually a debugger that lets you pause a program and look inside it.
Concept: the IDE as a programmer's workbench
How it works: an IDE combines an editor (with colour-coded syntax and automatic indentation),
a way to run your program, a console where output and errors appear, and a debugger.
Why we use it: it makes finding mistakes much faster. Both specifications expect you to know how
IDE features help a programmer: error diagnostics, breakpoints, stepping through code and watching variables.
Where else it's used: professional developers use IDEs such as VS Code, PyCharm and Visual Studio for
every language, and the same features (breakpoints, stepping, watches) appear in all of them.
Step 1: Is Python already installed?¶
On a school computer Python is often installed already. Open a terminal (Chapter 0.3 explains how) and type:
If you see something like Python 3.14.0, Python is installed and you can go to Step 3.
If you see an error, or the version starts with 2, you need to install it.
Which version?
This book needs Python 3.10 or newer. The newest version is usually the best choice, but check that any library you need supports it (Chapter 0.6 explains this for pygame-ce).
On a school computer?
You may not be allowed to install software. Ask your teacher or the IT team: they may already have Python and Thonny installed. Thonny comes with its own copy of Python, so on its own it is enough for the IGCSE chapters.
Step 2: Install Python¶
Python is free and comes from python.org, the official site. Get it from there (or from the Microsoft Store on Windows), not from a download site you found by searching.
Windows now has a Python install manager, which installs and updates Python for you. It replaces the older installer, which the Python developers have deprecated since Python 3.14.
- Install the Python install manager, either from the Microsoft Store (search for Python Install Manager) or from the Windows download page on python.org.
- Open a terminal and check it worked with
py --version. The first time, the install manager may need to download a Python runtime; Chapter 0.5 shows thepy installcommand that does this. - If anything seems wrong,
py install --configureruns a configuration checker that looks at your settings and suggests fixes.
Chapter 0.5 shows how to do all of this from the command line, and how to install more than one version.
Using the older installer?
If your computer uses the older python.org installer (the one with a checkbox list), tick Add python.exe to PATH on its first screen. Without it, the terminal cannot find Python. The older installer is not being made for Python 3.16 onwards.
macOS: download the macOS installer from python.org and run it. It installs a command called python3.
Chapter 0.5 shows how to install Python with Homebrew from the command line instead.
Linux: most distributions already include python3. Chapter 0.5 shows how to add anything missing.
Download Python from python.org
Search results can include look-alike sites. Only download Python from python.org (or the Microsoft Store on Windows).
Step 3: Choose an editor¶
All three of these are free.
| Editor | Good for | Notes |
|---|---|---|
| Thonny | Beginners, and the IGCSE chapters | Very simple. Has a debugger that shows variables changing as the program runs. Comes with its own copy of Python. |
| VS Code | Bigger projects and the graphical games | Install the Python extension from Microsoft, then choose your interpreter with Python: Select Interpreter. |
| IDLE | Quick tests | Installed with Python on Windows and macOS. Basic, but fine for short programs. |
Which one should I pick?
If you're new to programming, start with Thonny. You can move to VS Code later. The code is the same whichever editor you use.
Step 4: Write and run your first program¶
- Make a folder for your work, for example
Programmingin your Documents folder. -
In your editor, create a new file and type:
-
Save it as
hello.pyin your folder. The name must end in.py. - Run it: press Run (the green arrow in Thonny), or F5 in Thonny and IDLE.
What's happening?
print() is a built-in function: a piece of code that Python already has. Whatever you put between
the brackets is shown in the console. The text is inside quotation marks, so Python treats it as a
string (a piece of text) rather than as code.
Checkpoint
You have finished this chapter when hello.py runs and prints both lines.
Step 5: Meet your first error¶
Change the first line so the closing bracket is missing, and run it again:
Python refuses to run the program and shows a syntax error, with the line number where it got confused:
The exact wording depends on your Python version. Put the bracket back and the program runs again. Error messages are there to help you. Chapter 0.4 shows how to read them properly.
Common problems¶
| What you see | What to try |
|---|---|
'python' is not recognized… (Windows) |
Use py instead of python. If py isn't recognised either, Python isn't installed, or wasn't added to PATH. |
Typing python opens the Microsoft Store (Windows) |
Windows points python at the Store when it can't find Python. Use py, or install Python (Step 2). |
command not found: python (Mac) |
On a Mac, type python3, not python. |
The window flashes and closes when you double-click a .py file |
Run it from your editor or the terminal instead, so you can see the output. |
| Thonny uses a different Python from the terminal | That's normal: Thonny brings its own. Libraries installed in the terminal may not appear in Thonny, so use Thonny's Tools → Manage packages. |
Check your understanding¶
- What is the difference between an interpreter and an IDE?
- Give two features of an IDE that help a programmer find mistakes.
- Why should you download Python from python.org rather than from a site found by searching?
- A student types
python --versionon a Mac and seescommand not found. What should they type instead?
Answers
- The interpreter is the program that runs Python code. The IDE is the program you write code in; it usually runs the interpreter for you and adds tools such as a debugger.
- For example: error diagnostics that show the line of an error; breakpoints; stepping through code one line at a time; watching the values of variables; syntax highlighting.
- Other sites may offer out-of-date or tampered installers, which could contain malware. python.org is the official source.
python3 --version.
Summary¶
- You need an interpreter (Python) and an editor. An IDE combines them with tools for running and debugging.
- Get Python from python.org. On Windows, use the Python install manager.
- Thonny is best for beginners; VS Code suits bigger projects.
- A Python program is a text file ending in
.py. Run it with the Run button or F5.