๐ฆ What You'll Install Today
By the end of this lesson, you'll have two things on your machine:
1. Python 3.12+ โ the actual Python runtime that executes your code. Think of it as the engine.
2. Visual Studio Code โ the text editor where you'll write code, with a Python extension to make editing easier. Think of it as the steering wheel and dashboard.
Together, they form your development environment โ the workspace where every Python program starts.
๐ฏ The 5 Steps (Quick Overview)
๐ Meet Arjun & Aisha
Arjun is in Hyderabad, buying his first laptop for a career switch into AI. He's never coded before but follows step-by-step tutorials.
Aisha is in Nairobi, using a second-hand machine her friend gave her. The OS is old, and she's worried about compatibility.
Both will follow this exact guide. By the end, both will type python --version and see Python 3.12.x. Then they'll create a file hello.py, run it from VS Code, and see their first program output. Let's do it.
๐ Step-by-Step Installation
โฌ๏ธ Step 1: Download Python
Go to python.org โ the official Python website. Click the big yellow "Download" button. It auto-detects your OS.
You'll see a version like Python 3.12.7. That's fine โ any version 3.12 or higher works for this lesson. Download the installer (it's ~30 MB).
Note: If you're on an old Mac, you might get asked about Intel vs Apple Silicon. If your Mac was made after 2020, it's Apple Silicon. If older, it's Intel.
โ๏ธ Step 2: Install Python (Windows / Mac / Linux)
Windows
Double-click the downloaded installer. A window opens. IMPORTANT: Check the box "Add Python to PATH" at the bottom left. This is critical โ it lets you type python in your terminal later.
Then click "Install Now". It takes 2โ3 minutes. You might see a "User Account Control" prompt โ click "Yes".
At the end, you might see an option to "Disable path length limit". Click it if it appears.
macOS
Double-click the installer. It opens a wizard. Click "Continue" through each screen. When asked, choose "Install for all users" (or just your user, both work). Enter your Mac password when prompted.
At the end, you might see a note about SSL certificates. Ignore it for now โ we'll come back to it if needed.
Linux (Ubuntu / Debian)
Open a terminal. Type this command:
This uses your system's package manager to install Python. You'll be asked for your password (the sudo part). Type it and press Enter.
โ Step 3: Verify Installation
Open a new terminal or command prompt. Type this:
You should see output like Python 3.12.7 (or higher). pip is Python's package manager โ also essential. If you see this, Python is installed correctly.
๐ป Step 4: Download & Install VS Code
Go to code.visualstudio.com. Click "Download". Pick your OS. The download is ~50 MB.
Once downloaded, install it like any other program โ click the installer and follow the prompts. It takes ~1 minute.
After installation, launch VS Code. You'll see a welcome screen.
๐ Step 5: Install the Python Extension
On the left sidebar of VS Code, you'll see a grid icon (Extensions). Click it. Search for "Python" โ the official one is by Microsoft. Click "Install".
This adds Python language support, code completion, debugging, and more to VS Code. Installation takes ~30 seconds.
VS Code may ask if you want to "Select Python Interpreter". If it does, click "Yes" and choose the version you just installed (e.g., Python 3.12).
โ๏ธ Configuring VS Code (Quick Settings)
VS Code is usually auto-configured after the Python extension installs. But let's verify.
Open the Command Palette: Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac). Type Python: Select Interpreter. You should see your Python 3.12 version in the dropdown. Click it.
That's it! VS Code now knows where Python is on your machine.
Optionally, open Settings (Ctrl+, or Cmd+,) and search for "Format on Save". Toggle it on if you want VS Code to auto-format your code when you save files.
๐ Writing & Running Your First Script
Create a new folder somewhere on your computer โ call it python-practice. Open it in VS Code: File โ Open Folder.
Right-click in the empty file explorer on the left and create a new file. Call it hello.py.
Type this code:
Save the file (Ctrl+S or Cmd+S). Now run it. Click the play button (โถ) in the top-right corner of the editor, or press Ctrl+F5.
You should see the output in a terminal at the bottom of VS Code:
Congratulations โ you just ran your first Python program from VS Code. This is the moment every programmer remembers.
โ ๏ธ Common Installation Errors & Fixes
Windows: "'python' is not recognized"
Problem: You type python --version in Command Prompt and get an error saying the command wasn't found.
Fix: Python wasn't added to PATH during install. Reinstall Python. When you reach the installer screen, check the "Add Python to PATH" checkbox before clicking "Install". Then restart your terminal and try again.
Alternatively, search "Environment Variables" on your Windows machine, edit the PATH variable, and add the folder where Python is installed (usually C:\Users\YourName\AppData\Local\Programs\Python\Python312).
Mac: SSL Certificate Error
Problem: When you try to pip install libraries later, you see an SSL error about certificates.
Fix: After the Python installer finishes on Mac, look in your Applications folder for "Python 3.12" โ double-click the "Install Certificates.command" file. It's a one-click fix that handles SSL certificates.
Linux: Command Not Found or Permission Denied
Problem: python3.12 isn't in PATH, or pip fails with "Permission denied".
Fix: Use python3 instead of python โ that's the standard on Linux. If pip fails, run pip3 install --user package_name instead of sudo. The --user flag installs to your home directory without needing root access.
VS Code Doesn't Find Python
Problem: VS Code shows a red squiggly under Python code, saying "Pylance could not find Python".
Fix: Open the Command Palette (Ctrl+Shift+P), type "Select Interpreter", and manually choose your Python 3.12 installation from the list. If it's not there, click "Enter interpreter path..." and type the full path (e.g., /usr/bin/python3.12 on Linux or Mac).
๐ค Interview Questions
python3 is the command to run Python 3.x, while python sometimes refers to the old Python 2.x (if it's even installed). Since Python 2 reached end-of-life in 2020, always use python3 on Mac/Linux to be safe. On Windows with the Python installer, python is fine.python command from any folder in your terminal. Without it, you'd have to type the full path to the Python executable every time.pip install pandas. pip downloads the code from PyPI (Python Package Index) and installs it on your machine.C:\Python312). But your terminal doesn't automatically know where that is. By adding Python to PATH, the operating system checks that folder whenever you type a command. This lets you run python file.py from any terminal, any folder. Without PATH, your terminal would say "command not found". PATH is how the OS finds anything โ Python, git, npm, etc.๐ง Quick Quiz
๐ Installation Cheatsheet
| Command / Action | What It Does |
|---|---|
python --version | Check your Python version |
python3 --version | Same, on Mac/Linux (preferred) |
pip --version | Check pip (package manager) version |
pip install pandas | Install a package (e.g., pandas) |
code . | Open current folder in VS Code |
python hello.py | Run a .py file from terminal |
Ctrl+Shift+P | Open VS Code Command Palette (Windows/Linux) |
Cmd+Shift+P | Open VS Code Command Palette (Mac) |
Ctrl+` | Open/close terminal in VS Code |
F5 | Run current file in VS Code debugger |
โ ๏ธ Common Beginner Mistakes
โฆ Key Takeaways
- Download Python 3.12+ from python.org โ nowhere else
- During Windows installation, check "Add Python to PATH" โ it's critical
- Verify with
python --versionโ if it works, Python is installed - Download VS Code from code.visualstudio.com and install the official Python extension
- Configure VS Code to find your Python via Command Palette โ "Select Interpreter"
- Create a
.pyfile, type code, and press the play button to run it from VS Code - If PATH isn't set on Windows, reinstall Python and check the box โ or add it manually to Environment Variables
- On Mac, if you see SSL errors later, run
Install Certificates.commandfrom the Python folder
You've set up your first dev environment.
Now let's code.
Join the Best AI Program: The AI-Era Analyst โ 5 months, fully online, with placement assistance. Week 1 is free.
Explore The AI-Era Analyst โ