Setting up VS Code for Python
You can write Python in Notepad. You should not. A proper editor catches typos before you run anything, tells you what a function expects, and lets you step through code line by line when it misbehaves — which, in the debugging module, you will be very glad of.
We use VS Code. It is free, it runs on all three operating systems, and it is what a large share of working developers actually use. If you already use PyCharm and like it, stay there; everything in this course works the same.
Install VS Code
Download it from code.visualstudio.com and install it. The defaults are fine.
On Windows, the installer offers "Add to PATH" and "Open with Code" context menu entries. Tick both. They are genuinely convenient.
Install the Python extension
VS Code on its own does not know anything about Python. One extension fixes that.
- Open VS Code.
- Click the Extensions icon in the left bar — four squares, one detached — or
press
Ctrl + Shift + X(Cmdon Mac). - Search for Python.
- Install the one published by Microsoft. It will have tens of millions of downloads. Do not install a lookalike.
This one extension brings several things with it: error underlining as you type, autocomplete, the debugger, and test integration.
That is all you need. Resist the urge to install twenty extensions on day one — they slow the editor down and each one is another thing behaving in a way you do not understand yet.
Work in a folder, not in loose files
This is a small habit that prevents real confusion later.
Make a folder somewhere sensible — Documents/python-course is fine — and open
it in VS Code with File → Open Folder. Not File → Open File. The folder.
VS Code treats an open folder as your workspace. It remembers settings for it, the file explorer on the left shows it, and the terminal opens inside it. When you get to virtual environments in module 8, the whole design assumes you are working in a project folder. Starting the habit now costs nothing.
Tell VS Code which Python to use
If you have more than one Python installed — very common on macOS — VS Code needs to be told which one you mean.
- Press
Ctrl + Shift + P(Cmdon Mac) to open the command palette. - Type
Python: Select Interpreterand press Enter. - Choose the version you installed — 3.12 or newer.
The version you picked appears in the bottom-right status bar. When something later goes wrong in a way that makes no sense — a package you definitely installed is "not found" — check that corner first. It is the usual culprit.
The terminal inside VS Code
Press Ctrl + ` — the backtick key, above Tab — to open a
terminal panel at the bottom of the window. It opens in your project folder
already, which saves a lot of cd.
You will use this constantly. Get used to running your code here rather than clicking the ▶ button — not because the button is wrong, but because the command you type is the same command that will run on a server one day, and the button hides it from you.
Two settings worth changing
Open settings with Ctrl + , and search for each:
Format On Save — tick it. Your code gets tidied every time you save, so you stop thinking about spacing and start thinking about logic.
Render Whitespace → boundary. This shows faint dots for spaces. In Python,
indentation is not decoration — it is how the language knows what belongs inside
what. Being able to see your indentation prevents a whole category of
maddening bug where a line looks aligned but is indented with a tab instead of
spaces.
That second one is not fussiness. Mixed tabs and spaces is one of the most common
sources of IndentationError in beginner code, and it is invisible until you turn
this on.
Practice
- Install VS Code and the Microsoft Python extension.
- Create a folder called
python-courseand open it with File → Open Folder. - Select your interpreter, and check the version shows in the bottom-right.
- Open the integrated terminal and run
python --versioninside it. It should match what the status bar says. - Turn on Format On Save and whitespace rendering.
If step 4 shows a different version from step 3, that mismatch is worth fixing now — it will otherwise surface as a baffling error in a few weeks.
Next: your first actual program.
Stuck on this lesson?
Being stuck is part of it — but being stuck alone for three days is not. Our internship programme pairs this curriculum with code review and one-to-one help from working developers, and it is free.
About the internship