Concepts / Installing Python on GNU/Linux

Installing Python on GNU/Linux

Verification confirms that Python is installed on your Mac and accessible from the terminal.

  • Programming

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.

opentype application nameopenmacOS desktopSpotlightCommand + SpaceTerminalsearch resultTerminal windowcommand prompt
What sequence of actions takes you from the macOS desktop to an open Terminal window?
  1. Press Command + Space to open Spotlight.
  2. Search for Terminal.
  3. Open the Terminal application.
  4. 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.

python
enterstartdisplayreachTerminal promptready for inputpython3Python interpreterstartsVersion information>>>interactive prompt
How does entering python3 lead to terminal output that confirms whether Python is installed and accessible?

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.

Output
Python 3.9.7
Additional build and license information may appear here.
>>>
enterproducesleads toTerminal promptPython versionpython3>>>
What parts of the terminal response indicate that Python is ready to use?

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.

CommandTypical interpreterRecommended use
pythonOften Python 2 on systems that have both versionsDo not use for modern development when Python 3 is available
python3Python 3Use this command to work with the current standard version
often startsstartspythonPython 2often outdatedpython3Python 3actively maintained
How do the two command names differ, and which Python interpreter does each commonly start on macOS systems with both versions?

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.

python
EASY

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

  1. Open Spotlight with Command + Space.
  2. Search for and open Terminal.
  3. Enter python3 at the terminal prompt and press Enter.
  4. Look for a Python version number.
  5. Look for the >>> interactive prompt.
  6. Use exit() or Control + D to return to the regular terminal prompt.
  7. 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.