Understanding the Python Interactive Interpreter
Verification confirms that Python is installed and accessible on your GNU/Linux system by opening a terminal and running the python command.
Why Verification Comes First
Before writing Python programs, verify that Python is installed and accessible from your GNU/Linux terminal. This simple check can reveal an incomplete installation or a system path problem early. The process has a clear sequence: open a terminal, run the python command, and inspect what appears.
A successful launch shows Python version information, the Python prompt >>>, and no error messages.
Opening a GNU/Linux Terminal
The terminal is the gateway through which you run Python on GNU/Linux. You can open it from your system's application menu or launcher by locating and selecting the Terminal application. Another method is to press Alt + F2 to open a run dialog, type gnome-terminal, and launch the terminal window.
- Open the Terminal application from the system application menu or launcher.
- Alternatively, press Alt + F2 to open the run dialog.
- Type gnome-terminal in the run dialog and launch the terminal window.
- Wait for the terminal prompt and blinking cursor to appear.
Reading the Shell Prompt
When the terminal opens, a blinking cursor appears after a prompt. The prompt is a visual cue that the shell is ready to receive input. This article uses the dollar sign, $, as a simple representation of that prompt. You do not type the $ when an instruction shows it; you type only the command that follows.
The exact shell prompt varies with system settings, the user account type, and the shell configuration. It may include information such as a username, the computer's hostname, or the current directory path before the $ symbol. These visual differences do not change the basic action: enter the command after the prompt and press Enter.
Launching the Interactive Interpreter
Once the terminal prompt is visible, type python and press Enter. This launches the Python interactive interpreter. Python then displays several lines containing version information, the build date, the platform, and a reference to the license. Beneath that header, the prompt >>> appears.
Verifying a Python Installation
Determine whether Python is installed and accessible from an open GNU/Linux terminal.
Start at the shell: A prompt and blinking cursor show that the terminal is ready for input.
Enter python: Type python after the shell prompt and press Enter. Do not type the prompt symbol itself.
Inspect the response: A successful launch displays Python version information and other header details without an error message.
Find >>>: The >>> prompt shows that the Python interactive interpreter is running and waiting for Python code.
The installation is confirmed as accessible when Python starts, displays its information, and presents >>> without errors.
The >>> prompt is not another shell prompt. It indicates that Python has taken control of the terminal session and is waiting for Python code.
Checking the Version Without Entering Python
You can check the installed Python version without opening the interactive interpreter. At the shell prompt, enter python followed by the --version flag. The command prints the version number and returns immediately to the shell prompt.
This quick check is useful when you only need version information or when a script or automated check must confirm version compatibility before continuing. It differs from entering python by reporting the version and then returning to the shell instead of leaving you at the >>> prompt.
- At the shell prompt, enter python --version.
- Press Enter.
- Read the displayed version number.
- Confirm that the terminal returns to the shell prompt rather than opening the interactive interpreter.
Diagnosing a Missing Command
If entering python produces an error such as command not found or python: not found, the system either does not have Python installed or cannot locate it. In either case, the command did not successfully launch the interpreter, so you will not see the normal version information and >>> prompt.
- Check whether Python is installed by consulting the system's package manager or installation logs.
- If Python is installed, confirm that it is included in the system PATH, which is the list of directories where the shell searches for executable programs.
- If Python is installed but not in PATH, investigate whether it must be reinstalled or whether its location must be added to PATH.
- If terminal access methods or other troubleshooting steps differ on your GNU/Linux distribution, consult that distribution's documentation.
Common Prompt and Installation Mistakes
Typing the dollar sign as part of the command
The dollar sign represents the shell prompt and is not part of the command you enter.
Fix:
Type only python after the prompt.Treating >>> as the shell prompt
>>> indicates that the Python interactive interpreter is waiting for Python code.
Fix:
Exit the interpreter with exit() before entering shell commands.Assuming every shell prompt must look exactly like $
The prompt's appearance depends on system settings, the user account type, and shell configuration.
Fix:
Look for the cursor and the shell's ready-for-input prompt, even when additional information is displayed.Continuing as though Python launched after an error
The shell did not locate or launch Python.
Fix:
Check the installation and PATH, then consult distribution-specific documentation if needed.
Practice the Verification Sequence
On a GNU/Linux system, open a terminal using either the application menu or the Alt + F2 method. Then decide which command you would use for each goal: launching the interactive interpreter, checking the version without launching it, and returning to the shell after Python starts.
Hints
- The interactive interpreter is launched with python.
- The quick version check uses python followed by the --version flag.
- The interactive interpreter can be left with exit().
What do you think happens?
You enter python at the shell prompt and see version information followed by >>> with no error message. What does this tell you?
Reveal answer
Answer: Python is running and waiting for Python code
The version information confirms that Python started, and >>> is the Python interactive prompt. The absence of an error message confirms that the launch succeeded.
Verification Checklist
- Open a GNU/Linux terminal from the application menu, or use Alt + F2 and enter gnome-terminal.
- Treat the shell prompt as a visual cue that the terminal is ready; its appearance can vary across systems.
- Enter python, then look for version information, no error messages, and the >>> prompt.
- Use python --version when you need the version number without entering the interactive interpreter.
- If the shell reports command not found or python: not found, investigate the installation and PATH.
Key Takeaways
- The terminal provides access to Python commands on GNU/Linux.
- The shell prompt, represented here by $, is a cue to enter a shell command and is not typed as part of that command.
- Running python successfully displays version information and the >>> Python prompt.
- The >>> prompt means the interactive interpreter is ready for Python code, while exit() returns to the shell.
- Messages such as command not found or python: not found indicate that Python may be missing or inaccessible through PATH.