Concepts / Installing Python on Mac OS X

Installing Python on Mac OS X

A successful verification ends with Python running in the terminal and displaying the >>> interactive prompt.

  • Programming

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.

Key point

A successful verification ends with Python running in the terminal and displaying the >>> interactive prompt.

Opening Terminal with Spotlight

  1. 1
    Press Command + Space to open Spotlight search.
  2. 2
    Type Terminal into the search field.
  3. 3
    Open the Terminal application from the search results.
  4. 4
    Look 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

Terminal promptType a Python commandpython3Press EnterPython interpreterStarts if accessible>>>Ready for Python codeenterasks system to startsuccessful start
What happens when you enter a Python command in Terminal?

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.

python

Reading a Successful Result

Worked example

Recognizing a Working Python Interpreter

You enter python3 in Terminal and press Enter. How can you tell whether verification succeeded?

  1. 1
    Check the version line

    The output includes a Python version number, such as Python 3.9.7.

  2. 2
    Notice the additional information

    The terminal may also show information about the compiler, the build date, and the license.

  3. 3
    Find the interactive prompt

    The final prompt looks like three greater-than symbols: >>>. This means Python is running and waiting for Python code.

Result

The Python version and the >>> prompt together confirm that Python is installed and accessible from the terminal.

Terminal promptReady for a system commandPython versionFor example, Python 3.9.7python3Command entered>>>Interpreter is waitingentersuccessful startPython is running
Which parts of the terminal output indicate that Python is installed and accessible?

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.

python

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

CommandWhat it may launch on macOSRecommended use
pythonOften Python 2 on systems where both versions are availableDo not choose it when you need to ensure Python 3
python3Python 3Use this for modern development and verification

The command names can refer to different Python versions on many Mac systems.

pythonOften points to Python 2Python 2Outdated and unsupportedpython3Points to Python 3Python 3Current standard versionoften launcheslaunches
How do the python and python3 commands differ, and which Python interpreter does each command launch?

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 like

    An installer was run, but no Python command has been tested.

    Why it fails

    Installation and terminal accessibility are separate steps.

    Do this instead

    Open 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 like

    The command python starts an interpreter, but the version is Python 2.

    Why it fails

    On many Mac systems, python often points to the outdated Python 2 interpreter.

    Do this instead

    Use python3 for modern development and Python 3 verification.

  • Common mistake

    Assuming any output means verification succeeded

    What it looks like

    The command prints an error such as command not found.

    Why it fails

    An error indicates that Python is not installed or that the system cannot find it in its search path.

    Do this instead

    Install 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 like

    The terminal shows a dollar sign or percent sign, but Python has not started.

    Why it fails

    The regular terminal prompt accepts system commands. The >>> prompt indicates that the Python interpreter is running.

    Do this instead

    After entering python3, look for the Python version and the >>> prompt.

Verification Practice

EASY

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.
  1. 1
    Press Command + Space and open Terminal.
  2. 2
    Enter python3 and press Enter.
  3. 3
    Check for a Python version line and the >>> prompt.
  4. 4
    If both appear, Python is installed and accessible from the terminal.
  5. 5
    Enter exit() and press Enter to leave the Python prompt.

Ready to Write Python

  1. 1
    Use Command + Space to find and open Terminal with Spotlight.
  2. 2
    Run python3 to verify that Python 3 is installed and accessible.
  3. 3
    A Python version line shows which interpreter version started, and the >>> prompt shows that Python is running.
  4. 4
    On many Mac systems, python may point to outdated Python 2, so use python3 for modern development.
  5. 5
    After 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.

Related concepts

More concepts starting with I