Skip to content

Installing Python and VS Code

4 min read

Everything in the first lessons runs right here in your browser. Soon, though, you'll want Python on your own computer, where your programs can save files and keep running after you close the tab. In this lesson you'll install Python and a code editor, and check that both work. It takes about fifteen 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 in 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 first line borrows a built-in toolbox called sys that knows about the Python running your code; you'll learn about import later. On your computer, anything from 3.12 up is fine 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.

You'll also use the . It looks old-fashioned, but it's the most direct way to talk to Python.

Installing Python

Pick your system. The steps are different on each one.

On Windows, Python now comes through the Python install manager, a small app that installs and updates Python for you.

  1. Get the install manager

    Search for "Python Install Manager" in the Microsoft Store and install it. If you can't use the Store, download it from python.org/downloads instead. Both are the same app.

  2. Open a new terminal

    Press the Windows key, type PowerShell, and open it. Always open a new terminal after installing anything; old windows don't see new programs.

  3. Install Python

    Type this and press Enter. It downloads the latest Python and offers to fix your settings. Answer yes to its questions.

    py install --configure

Checking that it worked

In your terminal, ask Python for its version. On Windows the command is python; on macOS and Linux it's python3.

python --version

You should see one line with a version number, for example:

Output
Python 3.14.2

Your number may differ; 3.12 or higher is what matters. If you see that, Python is installed and your terminal can find it.

Notice that python --version is a command for the terminal, not Python code. The terminal and Python are two different places. Here's what happens if you give that same text to Python itself.

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 just text, so print shows it as it is. Python doesn't run terminal commands; only the terminal does.

And without the quotes, Python tries to understand it as code and fails. Run it and look at the last line.

python --version

In the editor, press Escape then Tab to move on.

Python says NameError: name 'python' is not defined. If you ever see this on your own computer, you typed a terminal command inside Python. Leave Python by typing exit() and pressing Enter, then run the command again in the plain terminal.

Quick check

You just installed Python, but your terminal says it can't find python. What should you try first?

Setting up VS Code

  1. Install VS Code

    Download it from code.visualstudio.com and install it with the default choices.

  2. 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.

  3. Open a folder for your code

    Make a folder called python-course anywhere you like. In VS Code, choose File, then Open Folder, and pick it. Every file you make in this course can live there.

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.

Output
Python is installed.
VS Code is installed.
The Python extension is installed.

Your code

# Print one line for each thing you installed

In the editor, press Escape then Tab to move on.

Show a 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; on macOS, use the installer from python.org; most Linux systems already have it.
  • Check your install in the terminal with python --version (Windows) or python3 --version (macOS and Linux).
  • Terminal commands and Python code are different things; don't type one into the other.
  • If the terminal can't find Python, open a new terminal first, then run py install --configure on Windows.
  • VS Code plus Microsoft's Python extension is your editor for this course.