Installing Python on GNU/Linux
Verification confirms that Python is installed on your Mac and accessible from the terminal.
From Installation to Readiness
Installing Python and verifying Python are different steps. Installation places Python on the computer, while verification checks that the terminal can find it and start it. This article focuses on the verification procedure described for Mac OS X: opening Terminal, running a Python command, and interpreting the response.
A successful verification means Python is installed and accessible from the terminal. It also means Python is ready for interactive experiments or for running Python script files.
Opening Terminal with Spotlight
On macOS, Spotlight is the built-in search tool used to open applications quickly. From the macOS desktop, press Command + Space, type Terminal, and open the Terminal application. The Terminal window will show a command prompt, usually ending with a dollar sign or percent sign. That prompt is where you type commands for the system to execute.
- Press Command + Space to open Spotlight.
- Search for Terminal.
- Open the Terminal application.
- Locate the command prompt, which commonly ends with a dollar sign or percent sign.
Running the Verification Command
After Terminal is open, enter a Python command at the command prompt and press Enter. The command asks the system to start Python and display version information. For modern Python work, use python3 so that you explicitly work with Python 3.
Reading a Successful Response
Recognizing a Working Python Installation
Determine whether the terminal response shows that Python is installed and accessible.
Check the version line: A successful response includes a Python version number. The source gives Python 3.9.7 as an example of the kind of version information that may appear.
Check the additional information: The response may also include information about the compiler, the build date, and the license.
Check the final prompt: The >>> prompt means that the Python interpreter is running and waiting for Python code.
A Python version number followed by the >>> prompt confirms that Python is installed and working from the terminal.
Python 3.9.7
Additional build and license information may appear here.
>>>python and python3 on macOS
Many Mac systems may have both python and python3 commands. The distinction exists because macOS historically shipped with Python 2, while Python 3 could also be installed by the user or by another application. The python command often points to Python 2, which is outdated and no longer supported. The python3 command points to Python 3, the current, actively maintained version described in the source material.
| Command | Typical interpreter | Recommended use |
|---|---|---|
| python | Often Python 2 on systems that have both versions | Do not use for modern development when Python 3 is available |
| python3 | Python 3 | Use this command to work with the current standard version |
When the Command Fails
Treating installation as proof that the terminal can run Python.
Installation and verification are separate steps. The terminal still needs to locate the Python command.
Fix:
Run python3 in Terminal and inspect the response.Using python when the goal is modern Python development.
The source identifies Python 2 as outdated and no longer supported.
Fix:
Use python3 to ensure that Python 3 is the interpreter being used.Interpreting the >>> prompt as an error.
The >>> prompt means Python is running and waiting for Python code.
Fix:
Treat the prompt as confirmation that verification succeeded.
If python or python3 produces a message such as command not found, Python may not be installed, or the system may be unable to find it in its search path. In that situation, install Python before continuing and consult a system administrator or the official Python installation guide for the macOS version.
Leaving the Interactive Prompt
After the >>> prompt confirms that Python is running, you can leave the Python interactive prompt by typing exit() and pressing Enter. You can also press Control + D. This returns you to the regular terminal prompt.
You open Terminal with Spotlight and enter python3. The response includes a Python version number and ends with >>>. What does this tell you, and what command can you use to return to the regular terminal prompt?
Hints
- The version number identifies the interpreter that started.
- The >>> prompt means the interpreter is waiting for Python code.
- The source gives two ways to exit the interactive prompt.
Verification Checklist
- Open Spotlight with Command + Space.
- Search for and open Terminal.
- Enter python3 at the terminal prompt and press Enter.
- Look for a Python version number.
- Look for the >>> interactive prompt.
- Use exit() or Control + D to return to the regular terminal prompt.
- If the command is not found, install Python or consult the appropriate installation guidance.
Key Takeaways
- Use Command + Space to open Terminal through Spotlight on macOS.
- Use python3 to verify that Python 3 is installed and accessible.
- A Python version number and the >>> prompt indicate a successful verification.
- The python command may refer to outdated Python 2, while python3 refers to Python 3.
- Installation and verification are separate steps.