Installing Python and VS Code
In this lesson you'll install Python and a code editor on your computer, and check that both work. Your own Python lets programs save files and keep running after you close the tab, and from Module 8 on you'll need it. It takes about twenty minutes, most of it waiting for downloads.
What you're installing
You need two things.
The first is Python itself: the that runs your code. The Python on this page is the same language, packed to run inside a browser. Press Run to ask it which version it is.
import sys
print("Python", sys.version_info.major, sys.version_info.minor)In the editor, press Escape then Tab to move on.
That means Python 3.14, the newest version. The first line borrows a built-in
toolbox called sys that knows about the Python running your code; you'll learn
import later. On your computer, anything from 3.12 up works for this course.
The second is a . We'll use VS Code: it's free, runs on Windows, macOS, and Linux, and has an official Python extension from Microsoft.
The downloads are large, so use Wi-Fi if you can. Python is about 50 MB on Windows and 80 MB on a Mac; VS Code is about 230 MB.
Opening a terminal
You'll type a few commands into the . If you've never used one, that's normal. Typing a command there is safe: the commands in this lesson only install and check things.
Windows
Press the Windows key, type PowerShell, and press Enter. The line where you
type starts with the folder you're in, then >:
PS C:\Users\Hana>macOS
Press Cmd + Space, type Terminal, and press Enter. The line where you type
ends in %:
hana@MacBook-Air ~ %Linux
Press Ctrl + Alt + T on most systems, or find Terminal in your apps. The line
where you type ends in $:
hana@laptop:~$That line is called the prompt. It's the terminal waiting for you. Type a command after it and press Enter.
Installing Python
Pick your system. The steps are different on each one.
Windows
Windows installs Python through the Python install manager, a small app from python.org that installs and updates Python for you. It needs Windows 10 or later.
Get the install manager
Open the Microsoft Store, search for Python Install Manager, and install it. If you can't use the Store, go to python.org/downloads and click Download Python install manager, then open the downloaded file. Both are the same app.
Open a new terminal
Open PowerShell as above. Always open a new terminal after installing something; windows that were already open don't see new programs.
Run the configuration checker
Type this and press Enter. It checks your settings and asks a few questions; type
yand press Enter to accept each one. If it offers to install the latest Python, say yes to that too.py install --configureCheck it
Ask Python for its version. The first time, it may download Python before answering, which takes a minute.
python --versionThen list the Pythons the install manager has set up:
py list
Older videos and tutorials show a different installer with an "Add Python to PATH" box to tick. That installer is being retired; the steps above are the current way.
macOS
Download the installer
Go to python.org/downloads and click the button to download the latest Python for macOS. It needs macOS 11 or later.
Run it
Open the downloaded
.pkgfile and click through the installer with the default choices.Check it
Open a new Terminal and type:
python3 --versionOn a Mac the command is
python3, with the 3. Plainpythonusually doesn't exist.
Linux
Most Linux systems already include Python. Check first:
python3 --versionIf it says the command isn't found, install it with your system's package manager, then check again:
# Ubuntu, Debian, Linux Mint
sudo apt install python3
# Fedora
sudo dnf install python3If it worked, you'll see one line with a version number, for example:
Python 3.14.7Your number may differ; 3.12 or higher is what matters.
Quick check
You typed python --version on a Mac and got command not found: python. What should you try?
Commands and code are different things
python --version is a command for the terminal, not Python code. The terminal and
Python are two different places. Here's what Python does with that same text in
quotes:
What will this print?
Decide before you look. Guessing wrong is how this sticks.
print("python --version")Python prints
python --version
Inside quotes, it's only text, so print shows it as it is. Python doesn't run terminal commands; only the terminal does.
You'll see what happens without the quotes, and how to tell which place you're in, in lesson 0.4.
Setting up VS Code
Install VS Code
Download it from code.visualstudio.com and install it with the default choices.
Add the Python extension
Open VS Code, click the Extensions icon on the left (or press Ctrl + Shift + X, Cmd + Shift + X on a Mac), search for Python, and install the one published by Microsoft.
Open a folder for your code
Make a folder called
python-courseanywhere you like. In VS Code, choose File, then Open Folder, and pick it. Every file you make in this course can live there.Choose your Python
Press Ctrl + Shift + P (Cmd + Shift + P on a Mac), type Python: Select Interpreter, and pick the newest Python in the list. This tells VS Code which Python runs your files.
Exercise
Check your setup
Write a program that prints three lines, one for each thing you installed, exactly
like this. Run it here first. Then save it as setup_check.py in your
python-course folder; you'll run that file from the terminal in lesson 0.4.
Python is installed.
VS Code is installed.
The Python extension is installed.Your code
# Print one line for each thing you installedIn the editor, press Escape then Tab to move on.
Show a solutionHide the solution
This is one way to solve it, not the only one. If yours prints the same thing, it works.
print("Python is installed.")
print("VS Code is installed.")
print("The Python extension is installed.")Key takeaways
- On Windows, install Python with the Python install manager and run
py install --configure; on macOS, use the installer from python.org; most Linux systems already have it. - Check it in the terminal:
python --versionon Windows,python3 --versionon macOS and Linux. - If Windows can't find
python, open a new terminal, trypy, then check the app execution aliases. - Terminal commands and Python code are different things.
- VS Code with Microsoft's Python extension is your editor for this course.