Python Course
Installing Python & Setting Up Your Environment
Before writing Python programs, your computer must understand the Python language. This happens through a program called the Python interpreter.
The interpreter reads your code line by line and executes it. Installing Python means installing that interpreter on your system.
In this lesson, you will install Python, verify the installation, and set up a professional coding environment.
Why Proper Installation Matters
If Python is not installed correctly:
- Your system will not recognize Python commands.
- You will not be able to run scripts from the terminal.
- Your editor may fail to detect Python.
A correct setup saves hours of troubleshooting later.
Step 1: Download Python
Always download Python from the official website. Never install Python from unknown sources.
- Choose the latest stable version (Python 3.x).
- Avoid outdated versions unless required.
Step 2: Install Python (Windows)
When running the installer on Windows, there is one critical option you must select:
Add Python 3.x to PATH
- Check the box before clicking “Install Now”.
- Without this, your system may not recognize the python command.
After selecting it, click Install Now and wait for completion.
Step 3: Verify the Installation
After installation, open Command Prompt (Windows) or Terminal (Mac/Linux). Type the following:
python --version
What This Command Does
pythoncalls the Python interpreter.--versionasks the interpreter to display its version.- If a version number appears, installation was successful.
If you see an error like “Python is not recognized,” PATH was not configured correctly.
Understanding the Terminal
The terminal (or command prompt) is a tool used to run programs using text commands. Professional developers use it daily.
When you run:
python test.py
pythonstarts the interpreter.test.pyis the file being executed.- The interpreter reads the file from top to bottom.
Step 4: Install a Code Editor
You can write Python in a basic text editor. However, a professional code editor improves productivity.
We recommend Visual Studio Code (VS Code).
After Installing VS Code
- Open VS Code.
- Go to Extensions.
- Search for Python.
- Install the official Python extension.
The extension provides:
- Syntax highlighting
- Code suggestions
- Linting support
- Debugging tools
Step 5: Run Your First File
Create a new file named test.py and write:
print("Python is installed successfully!")
Now open the terminal inside the same folder and run:
python test.py
What Just Happened?
- You created a Python file.
- The interpreter executed the file.
- The print() function displayed output.
- Your development environment is now functional.
Common Installation Issues
- "Python is not recognized" → PATH was not added.
- VS Code not detecting Python → Install Python extension.
- Multiple versions installed → Use
python3on Mac/Linux.
Practice
What program reads and executes Python code line by line?
Quick Quiz
Which setting allows Python to run from any folder?
Recap: You installed Python, understood what the interpreter does, verified the installation, and configured a proper coding environment.
Next up: Understanding Variables and Data Types.