Installing Python on GNU/Linux
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.
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.
- 1Press Command + Space to open Spotlight.
- 2Search for Terminal.
- 3Open the Terminal application.
- 4Locate 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.
- 1Check 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.
- 2Check the additional information
The response may also include information about the compiler, the build date, and the license.
- 3Check 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 |
The source describes these as common command distinctions on macOS; the exact availability can depend on the system.
When the Command Fails
Common mistake Treating installation as proof that the terminal can run Python.
What it looks likeAn installer was run, but the terminal responds that the command cannot be found.
Why it failsInstallation and verification are separate steps. The terminal still needs to locate the Python command.
Do this insteadRun python3 in Terminal and inspect the response.
Common mistake Using python when the goal is modern Python development.
What it looks likeThe python command starts Python 2 on a system that also has Python 3.
Why it failsThe source identifies Python 2 as outdated and no longer supported.
Do this insteadUse python3 to ensure that Python 3 is the interpreter being used.
Common mistake Interpreting the >>> prompt as an error.
What it looks likeThe terminal displays >>> after the version information.
Why it failsThe >>> prompt means Python is running and waiting for Python code.
Do this insteadTreat 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
- 1Open Spotlight with Command + Space.
- 2Search for and open Terminal.
- 3Enter python3 at the terminal prompt and press Enter.
- 4Look for a Python version number.
- 5Look for the >>> interactive prompt.
- 6Use
exit()or Control + D to return to the regular terminal prompt. - 7If 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.