Kids Web Dev
← Python courses

Python setup · 2 of 3

Set up VS Code for Python

VS Code is an editor for writing and saving code. Its built-in terminal lets you run that code using the Python you installed in the terminal setup lesson.

Install VS Code and the Python extension

  1. Have Python 3.10 or newer installed and a workbook ZIP extracted. If your setup check hasn’t printed Python is ready! yet, follow the terminal setup lesson first.

  2. Windows. Choose the Windows User Installer, open it, and follow the installer. Then open Visual Studio Code from the Start menu. Mac. Choose the Mac download. If it arrives as a ZIP, double-click it in Finder, move Visual Studio Code to Applications, and open it.

    Download Visual Studio Code
  3. Select Extensions in the left sidebar. Search for Python. Choose the extension published by Microsoft and select Install.

    Find the Microsoft Python extension

Open your workbook and select Python

  1. In VS Code, select File → Open Workspace from File. Pick the .code-workspace file in the folder that contains workbook.txt. It sets VS Code to run each Python file from its own folder. If asked whether you trust the folder, confirm you downloaded it from Kids Web Dev before accepting. You can also use File → Open Folder and run from the lesson folder in the terminal.

  2. In the Explorer sidebar, open setup and select check_python.py. Open the Command Palette with Ctrl+Shift+P on Windows or Command–Shift–P on Mac.

  3. Type Python: Select Interpreter and select that command. An interpreter is the program that runs your Python files. Select the Python 3 installation you checked in the terminal.

  4. With check_python.py open, click the triangle in the upper right of the editor. If it opens a menu, select Run Python File in Terminal. Look for the result in the Terminal panel at the bottom.

    What you should see · Python is ready!

  5. If you prefer typing the command, choose Terminal → New Terminal. Open it from the workbook folder and use the Windows or Mac command below.

    py setup\check_python.py
    
    python3 setup/check_python.py

Open an online lesson in VS Code

  1. From the online lesson, expand Practice in VS Code. Use the current workbook ZIP for that course. The lesson link points to files inside the extracted copy.

  2. Windows. In File Explorer, right-click the extracted workbook folder and choose Copy as path. If the option isn’t there, open the folder and copy its path from the address bar. Mac. Select the extracted folder in Finder and press Option–Command–C. Choose the folder containing workbook.txt.

  3. Paste the path under Workbook folder on this computer and choose Save workbook folder. Choose Open example in VS Code or Open starter in VS Code. If the browser asks to open Visual Studio Code, choose Open.

  4. In VS Code, run the open file with the triangle. To work offline, just open the lesson files in the Explorer sidebar. Save edits with Ctrl+S on Windows or Command–S on Mac. Your edits are saved inside your local workbook folder.

If VS Code can’t run the file

  1. If Python: Select Interpreter or the triangle is missing, check that the active file ends in .py and that the Microsoft Python extension is installed and enabled. Reopen VS Code, then select the interpreter again.

  2. If the interpreter list is empty, check Python in a separate terminal first. If the version command works there, close and reopen VS Code to pick up the installation.

  3. If the online link opens an empty editor or doesn’t launch VS Code, check that the ZIP was extracted and the saved path points to the correct course folder. You can always open the files through File → Open Folder and run them there.

Next · Run a Python file on Windows or Mac →