In this lesson, you will learn how to install the Python interpreter and configure your computer to recognize the python command from any folder on your system.
Installing the Interpreter
To run Python code, you need the Python interpreter—a program that reads your code and translates it for your computer. Head over to python.org, download the latest version for your operating system, and run the installer.
The "Add to PATH" Magic
During the installation process, you will see a critical checkbox that says "Add Python to PATH". You must check this box.
Think of your "PATH" as a list of folders that your computer searches whenever you type a command into your terminal or command prompt. If you type python but your computer doesn't know where the Python program lives, it will return an error like command not found. By checking "Add to PATH," you are telling your operating system exactly where to look for the Python interpreter, allowing you to run scripts from any directory.
Verifying Your Setup
Once the installation is finished, open your terminal (Command Prompt on Windows, Terminal on macOS/Linux) and type the following command:
python --version
If the installation was successful and the PATH was updated correctly, you will see the version number printed back to you (e.g., Python 3.12.x).
If you get an error instead, the system cannot find Python yet. On Windows, you can manually add the installation folder (where python.exe is located) to your "Environment Variables" in the System Settings. On macOS or Linux, this is typically handled by your shell profile (like .zshrc or .bashrc), where you add the export path for your Python installation. Once this is set, your terminal becomes a powerful tool ready to execute any Python script you create, regardless of where you saved the file on your hard drive.
Key Takeaway: Adding Python to your system PATH is the essential step that allows your computer to find and execute the Python interpreter from any command-line interface.