How to run Python

Check Python 3

Open a terminal and ask Python for its version. Most macOS and Linux systems use python3; on Windows, the py launcher is usually the most reliable choice.

python3 --version
# Windows alternative:
py --version

Use the interactive prompt

Run Python without a filename to open the REPL. Each expression is evaluated immediately, which is useful for quick experiments. Leave with exit().

python3
>>> 2 + 3
5
>>> print("Ready")
Ready
>>> exit()

Run a script

Save the example as hello.py, change the terminal to that folder, and pass the filename to Python. Windows users can substitute py.

print("Python is running!")

# Terminal command:
python3 hello.py

Fix common launch problems

A “command not found” message usually means Python is not installed or is not on PATH. Install Python 3 from python.org or your operating system package manager, then reopen the terminal.

  • Prefer python3 so you do not accidentally run legacy Python 2.
  • On Windows, try py script.py when python3 is unavailable.
  • Confirm the current folder and filename when Python says it cannot open a file.