Module 1 · Introduction to Python — topic 8 of 14
Installing Python
Step-by-step installation of Python 3 on Windows, macOS and Linux, how to check the installation from a terminal, and how to fix the most common setup problems.
Learning objectives
- Install Python 3 on your operating system
- Verify the installation from a terminal
- Fix the ‘python is not recognised’ problem
Definition
Step-by-step installation of Python 3 on Windows, macOS and Linux, how to check the installation from a terminal, and how to fix the most common setup problems.
Introduction
Before you can run Python files on your own computer you need the Python interpreter installed. The official, free installer is available from python.org for Windows and macOS, and most Linux systems already include Python 3.
Installation takes a few minutes. The only step that commonly goes wrong is the PATH setting on Windows, which this lesson explains carefully.
Why it matters
Running code locally lets you work offline, save your programs as files and build the projects in this course. The browser examples on this site are useful for reading, but real programs live on your computer.
Detailed explanation
Windows: download the latest Python 3 installer from python.org/downloads. On the first screen tick “Add python.exe to PATH”, then choose Install Now. PATH is the list of folders Windows searches for programs; adding Python lets you type python in any terminal.
macOS: download the macOS installer from python.org and run it. Afterwards use the python3 command in Terminal (the plain python command may not exist).
Linux: most distributions include Python 3. Check with python3 --version. If it is missing, install it with your package manager, for example sudo apt install python3 python3-venv on Ubuntu.
Verify: open a new terminal window (Command Prompt or PowerShell on Windows) and type python --version or python3 --version. You should see something like Python 3.13.1.
Opened the terminal before installing?
Close it and open a new one. Terminals read PATH only when they start.
Syntax
- python --version works on Windows (and on systems where python means Python 3).
- python3 --version is the usual command on macOS and Linux.
- py --version uses the Windows Python launcher, which is installed with Python.
Code examples
Confirming Python from inside Python
Python 3
Where is the interpreter?
True
sys.executable holds the full path of the running interpreter, useful when you suspect two Pythons are installed.
More examples
A setup check script
Operating system detected: True Python 3.10 or newer: True Ready for the course
Step-by-step explanation
- platform.system() returns the operating system name, such as Windows, Darwin or Linux; bool() turns any non-empty name into True.
- sys.version_info can be compared with a tuple such as (3, 10).
- ok is True when the version is 3.10 or newer, which every lesson in this course supports.
- The last line prints one message or the other using a conditional expression.
Expected output
Running “A setup check script” prints exactly:
Practical applications
- Development teams document the required Python version in the project README.
- Continuous-integration servers install a specific Python version before running tests.
- IT departments install Python on lab computers with the PATH option enabled for students.
Best practices
- Install the latest stable Python 3 version from python.org.
- Avoid installing several versions unless a project requires it.
- Always check the version in a fresh terminal after installing.
Common mistakes
‘python’ is not recognised as a command
Avoid
Prefer
Windows can’t find programs that aren’t on PATH.
Typing python inside the Python shell
Avoid
Prefer
The >>> prompt means you are already inside Python, which expects Python code, not terminal commands.
Key takeaways
- Download Python 3 from python.org; Linux usually has it already.
- On Windows, tick “Add python.exe to PATH”.
- Check with python --version, python3 --version or py --version.
Try it yourself
- 1Install Python on your computer and record the exact version number that python --version shows.
- 2Run the setup check script and confirm it prints “Ready for the course”.
Finished reading? Mark it complete to update your dashboard.
Suggested practice
1 question test this exact topic. Answers and explanations are revealed after you submit.
- BeginnerWhich command shows the installed Python version?