Configuring the PATH Variable
PATH configuration matters because it allows the python command to launch the interpreter directly from the Windows command line. The visible sign of the transition is the change from the Windows command-line prompt to the Python prompt.
From Windows to Python
Once Python is installed and the PATH variable is properly configured, you can start Python directly from the Windows command line. This creates a short sequence of environments: Windows provides the command-line terminal, the terminal receives the python command, and the Python interpreter starts and presents the >>> prompt. The main skill is recognizing which environment is active at each stage.
What do you think happens?
After entering python at the Windows command prompt, which prompt should appear when the interpreter is ready?
Reveal answer
>>>
The three greater-than symbols indicate that the Python interpreter is active and waiting for Python code. The Windows command-line prompt is different and expects Windows commands.
Opening the Command Line
Begin by opening the Windows command-line terminal. Click the Start button, click Run, type cmd in the Run dialog, and press Enter. A new window opens with the Windows command prompt and a blinking cursor ready for input.
- 1Click Start.
- 2Click Run.
- 3Type cmd in the dialog box.
- 4Press Enter.
- 5Wait for the Windows command prompt window to open.
How PATH Finds Python
When you type python at the Windows command prompt and press Enter, Windows uses the configured PATH variable to find and execute the Python interpreter. If the PATH variable is properly configured, the command can launch Python directly from the command line. The result is a transition from the Windows terminal environment into the Python interpreter.
PATH configuration matters because it allows the python command to launch the interpreter directly from the Windows command line. The visible sign of the transition is the change from the Windows command-line prompt to the Python prompt.
Launching and Checking Python
Starting an Interactive Python Session
You have opened the Windows command prompt and want to start Python directly from it.
- 1Enter the launch command
At the Windows command prompt, type python and press Enter. Windows uses the configured PATH variable to find and execute the Python interpreter.
- 2Observe the startup information
Python displays version information. The exact version number depends on the Python version installed on the system.
- 3Check the prompt
Look for >>>. This shows that the Python interpreter is active and ready to accept Python code.
- 4Recognize the environment change
The >>> prompt means that input is now interpreted as Python code rather than as a Windows command.
Python has started successfully when version information is displayed and the >>> prompt appears.
| Environment | Prompt | Expected input |
|---|---|---|
| Windows command line | C:\Users\YourName> or similar | Windows commands and commands that launch applications |
| Python interpreter | >>> | Python code |
The prompt identifies which environment will interpret what you type.
Leaving the Interpreter
After Python has started, you are inside the interpreter rather than directly at the Windows command line. To return to the Windows command line, type exit() at the >>> prompt and press Enter. The prompt changes back to a Windows command-line prompt such as C:\Users\YourName> or a similar prompt.
Mistakes with the Two Prompts
Common mistake Typing python before opening the Windows command-line terminal
What it looks likeThe launch command is entered before using Start, Run, cmd, and Enter to open the terminal.
Why it failsThe described process begins at the Windows command prompt. Without that terminal, there is no command-line environment in which to enter python.
Do this insteadOpen the terminal first by clicking Start, clicking Run, typing cmd, and pressing Enter.
Common mistake Assuming that the Windows prompt and the Python prompt are the same
What it looks likeTreating C:\Users\YourName> and >>> as interchangeable.Why it failsThe Windows command line and the Python interpreter are distinct environments that expect different kinds of input.
Do this insteadUse the Windows prompt for Windows commands and use >>> for Python code.
Common mistake Assuming Python is ready without checking the startup signs
What it looks likeContinuing without looking for version information and the >>> prompt.
Why it failsThe source identifies version information and >>> as the visible signs that the interpreter has started correctly.
Do this insteadVerify both the version information and the >>> prompt before entering Python code.
Common mistake Trying to leave Python by treating exit() as a Windows command
What it looks likeForgetting that exit() is entered at the Python prompt.
Why it failsThe instruction to return to the Windows command line applies to the Python interpreter environment.
Do this insteadAt the >>> prompt, type exit() and press Enter.
Guided Terminal Check
Perform the complete sequence on a Windows system: open the Run dialog through Start, type cmd, press Enter, type python at the Windows command prompt, and press Enter. Record which prompt appears after the Python version information. Then identify which environment is active and use the appropriate command to return to the Windows command line.
Hints
- The Windows prompt looks similar to C:\Users\YourName>.
- The Python prompt consists of three greater-than symbols.
- The command used to return from Python is
exit().
PATH Configuration Takeaways
- 1Open the Windows command-line terminal through Start, Run, cmd, and Enter.
- 2Type python at the Windows command prompt and press Enter to launch the interpreter when PATH is properly configured.
- 3Confirm startup by looking for Python version information and the >>> prompt.
- 4Remember that the Windows command-line prompt expects Windows commands, while >>> expects Python code.
- 5Use
exit()at the Python prompt to return to the Windows command line.
At a glance
- The Run dialog provides a direct way to open the Windows command-line terminal.
- A properly configured PATH variable allows the python command to launch the Python interpreter from that terminal.
- Python startup is confirmed by version information and the >>> prompt.
- The Windows command line and the Python interpreter are separate environments with different prompts and expected inputs.
- Typing
exit()at the Python prompt returns control to the Windows command line.