Installing & Running Python
To write Python on your own computer you need the Python interpreter and an editor. This lesson covers installing Python on each operating system, checking it works, and the three ways you'll run code: the interactive shell, script files and notebooks.
Check whether Python is already installed
Open a terminal (Command Prompt or PowerShell on Windows, Terminal on macOS/Linux) and type:
python3 --version
Python 3.14.0
On Windows the command is usually python or the launcher py. If you see a version of 3.12 or newer, you're ready. If you get "command not found" or an older version, install it as below.
Installing Python
| System | How |
|---|---|
| Windows | Download the installer from python.org, or install "Python 3.x" from the Microsoft Store. In the python.org installer, tick "Add python.exe to PATH". |
| macOS | Download the installer from python.org, or with Homebrew: brew install python. The python3 that ships with Apple's developer tools is often outdated. |
| Linux | Usually pre-installed. Otherwise use your package manager, e.g. sudo apt install python3 python3-venv. |
A popular modern alternative is uv, a fast tool that can install and manage Python versions and project dependencies with one command (uv python install). Lesson 47 covers project tooling.
The interactive shell (REPL)
Type python3 on its own to start an interactive session. The >>> prompt runs each line as you press Enter and shows the result immediately:
$ python3 >>> 2 + 3 5 >>> name = "Ada" >>> name.upper() 'ADA' >>> exit()
The shell (also called the REPL — Read, Evaluate, Print, Loop) is perfect for quick experiments and checking how something behaves. Notice that it displays the value of an expression without needing print; in a script file, you must use print.
Script files
For real programs, write code in a file ending in .py and run it:
greeting = "Hello from a script" print(greeting) print("2 + 2 =", 2 + 2)
python3 hello.py
Hello from a script 2 + 2 = 4
Choosing an editor
- VS Code with Microsoft's Python extension — free, popular, with debugging, linting and notebook support.
- PyCharm — a full Python IDE; the Community edition is free.
- IDLE — the simple editor that comes with Python; fine for beginners.
- Jupyter notebooks — run code in cells with output shown inline; the standard tool for data analysis. Available in VS Code or via
pip install jupyterlab.
Whatever you choose, configure it to indent with 4 spaces — the Python convention.
Running Python in the browser
The editors on this site use Pyodide, a version of Python compiled to run inside the browser. It's real CPython, so code behaves just as it does on your computer, with a few limits: there's no access to your real files, input() isn't interactive, and some packages aren't available. Online services like Google Colab and the official Python shell at python.org/shell are other no-install options.
Try it yourself
python3 works but python doesn't (or vice versa), that's normal — different systems name the command differently. Use whichever one prints a 3.x version.