Topic 24 of 64
Interpreter Installation
Overview
The Python interpreter is the runtime that executes your .py scripts. Installing the right version (3.10+) and verifying it via terminal ensures your code behaves consistently across all machines — critical for reproducibility in teams.
Syntax
bash
# Check Python version
python3 --version # macOS/Linux
python --version # Windows
# Run a script
python3 script.py
# Interactive REPL
python3Common Pitfalls
- On macOS, 'python' may still point to Python 2.7 — always use 'python3' explicitly.
- Use pyenv to manage multiple Python versions without conflicts: pyenv install 3.11.0 && pyenv global 3.11.0.
- Interview tip: Interviewers expect you to know python3 vs python distinction and how to check the active interpreter path with 'which python3'.
Real-World Example
Set up Python 3.11 and run a hello world script from terminal
example
bash
# Install (macOS via Homebrew)
brew install python@3.11
# Confirm version
python3.11 --version # Python 3.11.x
# Run script
python3.11 hello.py