Python on macOS, Windows, Linux
You'll learn: How the python command works differently across operating systems and what PATH means for running Python.
The Python Command Varies by OS
When you installed Python and verified it works, you typed a command in your terminal or command prompt. But the exact command can differ depending on your operating system!
On macOS and Linux
These systems often come with Python 2 pre-installed (though this is changing). When you type python, it might launch Python 2. To explicitly use Python 3, you typically type:
python3 --version
On Windows
Windows doesn't come with Python pre-installed. After you install Python 3 from python.org, the command is usually just:
python --version
Though python3 may also work depending on how you installed it.
What is PATH?
Think of PATH like your computer's address book for programs. When you type python in a terminal, your computer looks through a list of folders (the PATH) to find where the python program lives. If Python's folder isn't in PATH, your computer can't find it—that's why the installer asks to "Add Python to PATH."
Why This Matters
If you follow a tutorial written for macOS but you're on Windows, commands might differ slightly. Don't panic! You're not doing it wrong—the tutorial just assumed a different OS. Try python first; if that doesn't work, try python3.
Key Takeaway: The command to run Python varies by OS—python3 is common on macOS/Linux, while python typically works on Windows after installation. PATH tells your computer where to find Python.