1.2.1Introduction to Programming (Python)

Installing Python + VS Code — environment setup

1,728 words8 min readdifficulty · medium

WHAT are we actually installing?

WHY two pieces? Because writing and running are different jobs. Many editors exist (PyCharm, Sublime, even Notepad); many ways to run Python exist (terminal, IDE). Keeping them separate makes the system flexible.


HOW the pieces fit together

Figure — Installing Python + VS Code — environment setup

HOW to install — step by step

Step 1 — Install the Python interpreter

  1. Go to python.org → Downloads and get the latest stable version (e.g. Python 3.12).
  2. Run the installer.CHECK the box "Add Python to PATH" at the bottom.
    • Why this step? Without it, your terminal won't recognise the word python, and you'll get "python is not recognized". PATH is how the OS finds the program.
  3. Click Install Now.

Verify it (Active Recall the machine!): open a terminal and type:

python --version

Expected: Python 3.12.x. (On macOS/Linux you may need python3 --version.)

Step 2 — Install VS Code

  1. Go to code.visualstudio.com, download for your OS, install (defaults are fine).
  2. On Windows, tick "Add to PATH" so you can type code . to open a folder.

Step 3 — Connect the two (the part people forget)

  1. Open VS Code → Extensions (the four-squares icon) → search "Python" (by Microsoft) → Install.
    • Why? This gives the green Run ▶ button, syntax help, and the interpreter selector.
  2. Open a folder for your project: File → Open Folder.
  3. Select interpreter: press Ctrl/Cmd+Shift+P → type "Python: Select Interpreter" → pick your Python 3.12.
    • Why this step? You may have several Pythons; this tells VS Code which brain to use for this project.

Step 4 — First program

Create hello.py:

print("Hello, world!")

Press Run ▶. The terminal shows Hello, world!. Why this step? It proves all three layers work: editor saved the file, interpreter is found, output flows back.

Step 5 (best practice) — A virtual environment

In the VS Code terminal:

python -m venv .venv

Then select .venv as the interpreter (VS Code usually prompts you).

  • Why? So installing a library for this project (pip install requests) never breaks a different project. Isolation = no version wars.

Steel-man your mistakes


The 80/20 — what actually matters


Recall Feynman: explain to a 12-year-old

Imagine you want to write and read letters in a secret language. Python is your friend who understands the secret language — you hand him a note and he reads it out loud. VS Code is your nice desk with good pens and a lamp where you write the notes neatly. The desk doesn't understand the language — it just helps you write. So you need BOTH: the desk to write, the friend to read. "Add to PATH" is like putting your friend's phone number in your contacts so you can call him instantly by name from anywhere in the house.


Flashcards

What two separate things must you install for Python development?
The Python interpreter (runs code) and a code editor like VS Code (writes code).
Why must you tick "Add Python to PATH" during installation?
So the operating system can find the python command from any terminal; otherwise you get "python is not recognized".
What does VS Code actually do when you press Run?
It opens a terminal and calls the selected Python interpreter to execute your file — it doesn't run Python itself.
What command verifies your Python install and version?
python --version (or python3 --version) → prints Python 3.x.x.
What is the VS Code "Python: Select Interpreter" command for?
To tell VS Code WHICH installed Python to use for the current project.
What is a virtual environment (venv) and why use it?
An isolated Python+libraries copy per project, created with python -m venv .venv, so projects' dependencies don't clash.
On macOS/Linux, what do you try if python says "command not found"?
Use python3 (and pip3); the system often doesn't map plain python.
What does the Microsoft Python extension add to VS Code?
Run button, syntax highlighting/linting, debugging, and the interpreter selector.

Connections

  • Python Interpreter vs Compiler
  • The Terminal and Command Line Basics
  • pip and Package Management
  • Virtual Environments (venv)
  • Your First Python Program — print()
  • PATH Environment Variable

Concept Map

step 1 install

step 2 install

reads and runs .py

added to

lets OS find

needs

teaches VS Code about

opens

calls selected

hosts Run button

isolated copy per project

Environment setup

Python interpreter

VS Code editor

PATH variable

Python extension

Virtual environment

Terminal

Run button

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, sabse pehle samajh lo ki Python aur VS Code do alag cheezein hain. Python ek interpreter hai — yeh asli mein tumhara code padhta aur chalata hai, isko "dimaag" samajh lo. VS Code sirf ek acha sa editor hai jahan tum code likhte ho, comfortable typing, colors, autocomplete ke saath — isko "haath" samajh lo. Bahut log galti karte hain ki sirf VS Code install kar lete hain aur sochte hain Python bhi aa gaya — nahi bhai, dono alag se install karne padte hain.

Install karte waqt sabse important baat: python.org se installer chalao aur "Add Python to PATH" wala box zaroor tick karo. Yeh PATH cheez tumhare operating system ko batati hai ki python command kahan dhoondhni hai. Agar tick nahi kiya, to terminal bolega "python is not recognized" — bas yahi sabse common dard hai beginners ka. Verify karne ke liye terminal mein python --version likho; agar Python 3.x.x aaya, to interpreter sahi laga.

Phir VS Code install karo, uske baad Extensions mein jaake Microsoft ka Python extension install karo — yeh green Run button aur interpreter selector deta hai. Ctrl+Shift+P daba ke "Python: Select Interpreter" chuno taaki VS Code ko pata chale konsa Python use karna hai. Last mein har project ke liye python -m venv .venv se ek virtual environment banao, taaki ek project ki library doosre project ko na todge. Bas itna — interpreter, editor, extension, select, verify, venv. Yeh 20% setup hi 80% kaam aasaan kar deta hai.

Test yourself — Introduction to Programming (Python)

Connections