Installing Python on Mac OS X
A successful verification ends with Python running in the terminal and displaying the >>> interactive prompt.
Installation Versus Verification
Installing Python and verifying Python are different steps. An installer may have been run, but that does not automatically prove that the terminal can find and start Python. Verification is the bridge between installation and actual use: it confirms that Python is installed on your Mac and accessible from the terminal.
A successful verification ends with Python running in the terminal and displaying the >>> interactive prompt.
Opening Terminal with Spotlight
- 1Press Command + Space to open Spotlight search.
- 2Type Terminal into the search field.
- 3Open the Terminal application from the search results.
- 4Look for the terminal prompt, which usually ends with a dollar sign or percent sign.
Terminal is the command-line interface where you run commands for the system to execute. The dollar sign or percent sign is the regular terminal prompt. It shows where you can type a command; it is not part of the command itself.
From Command to Interpreter
When you enter a Python command and press Enter, the command asks the system to start a Python interpreter and display its version information. If the system can find the interpreter, Python starts inside the terminal. The >>> prompt then shows that Python is running and waiting for Python code.
Reading a Successful Result
Recognizing a Working Python Interpreter
You enter python3 in Terminal and press Enter. How can you tell whether verification succeeded?
- 1Check the version line
The output includes a Python version number, such as Python 3.9.7.
- 2Notice the additional information
The terminal may also show information about the compiler, the build date, and the license.
- 3Find the interactive prompt
The final prompt looks like three greater-than symbols: >>>. This means Python is running and waiting for Python code.
The Python version and the >>> prompt together confirm that Python is installed and accessible from the terminal.
The version line proves that the interpreter started and identifies the Python version. The >>> prompt is the strongest sign that Python is active: the terminal is no longer waiting for a regular system command; it is waiting for Python code.
Type exit() and press Enter to leave the Python interactive prompt and return to the regular terminal prompt. You can also press Control + D.
Choosing python or python3
| Command | What it may launch on macOS | Recommended use |
|---|---|---|
| python | Often Python 2 on systems where both versions are available | Do not choose it when you need to ensure Python 3 |
| python3 | Python 3 | Use this for modern development and verification |
The command names can refer to different Python versions on many Mac systems.
Many Mac systems may have both command names available because macOS historically shipped with Python 2 and Python 3 could later be installed by the user or another application. On such systems, python often points to Python 2, while python3 points to Python 3. Python 2 is outdated and no longer supported, so use python3 when you need to work with the current version of the language.
Handling Verification Errors
Common mistake Treating installation as proof that Terminal can use Python
What it looks likeAn installer was run, but no Python command has been tested.
Why it failsInstallation and terminal accessibility are separate steps.
Do this insteadOpen Terminal and run python3 to verify that the system can find and start Python.
Common mistake Using python when the goal is specifically Python 3
What it looks likeThe command python starts an interpreter, but the version is Python 2.
Why it failsOn many Mac systems, python often points to the outdated Python 2 interpreter.
Do this insteadUse python3 for modern development and Python 3 verification.
Common mistake Assuming any output means verification succeeded
What it looks likeThe command prints an error such as command not found.
Why it failsAn error indicates that Python is not installed or that the system cannot find it in its search path.
Do this insteadInstall Python before proceeding, consulting a system administrator or the official Python installation guide for the macOS version.
Common mistake Confusing the regular terminal prompt with the Python interactive prompt
What it looks likeThe terminal shows a dollar sign or percent sign, but Python has not started.
Why it failsThe regular terminal prompt accepts system commands. The >>> prompt indicates that the Python interpreter is running.
Do this insteadAfter entering python3, look for the Python version and the >>> prompt.
Verification Practice
Open Terminal with Spotlight, run python3, and decide whether the installation is verified. Then explain what the version line and the >>> prompt tell you. Finally, leave the Python interactive prompt with exit().
Hints
- Use Command + Space to open Spotlight.
- A successful result includes a Python version number.
- The >>> prompt means that Python is running and waiting for Python code.
- Use
exit()to return to the regular terminal prompt.
- 1Press Command + Space and open Terminal.
- 2Enter python3 and press Enter.
- 3Check for a Python version line and the >>> prompt.
- 4If both appear, Python is installed and accessible from the terminal.
- 5Enter
exit()and press Enter to leave the Python prompt.
Ready to Write Python
- 1Use Command + Space to find and open Terminal with Spotlight.
- 2Run python3 to verify that Python 3 is installed and accessible.
- 3A Python version line shows which interpreter version started, and the >>> prompt shows that Python is running.
- 4On many Mac systems, python may point to outdated Python 2, so use python3 for modern development.
- 5After successful verification, you can experiment at the interactive prompt or run Python script files from Terminal.
Verification completes the connection between having Python installed and being ready to use it. Once the terminal starts Python and displays the >>> prompt, you can move on to writing Python code.
Key Takeaways
- Spotlight provides a quick way to open Terminal on Mac OS X.
- Running python3 checks whether Python 3 is installed and accessible from the terminal.
- A displayed Python version and the >>> prompt indicate a successful verification.
- The python command may point to outdated Python 2 on systems that have both versions, so prefer python3.
- If the command is not found, Python is not installed or the system cannot locate it in its search path.