This survey presentation will focus on developing Python projects with Visual Studio Code (VS Code) on the Raspberry Pi. The principles demonstrated can be applied to other languages supported by the Pi and other SBC.
An integrated development environment (IDE) is a comprehensive software application that combines project editing, debugging, version control, and other development tools into one platform. The code editor in an IDE typically offers features like syntax highlighting and autocompletion to enhance productivity. The built-in graphical debugger allows developers to set breakpoints, inspect variables, and step through their code for troubleshooting. Most IDEs include Git integration, providing a user-friendly interface for common version control tasks such as staging, committing, pushing, and pulling. Additionally, IDEs often support multiple programming languages and can be extended with plugins or extensions to include a wide range of development tools.
https://en.wikipedia.org/wiki/Integrated_development_environment
Why VS Code? Popularity. In the 2023 Python Software Foundation and JetBrains and Stack Overflow developer surveys, VS Code was the most used IDE.
Here is a table of the most popular IDEs, that support Python and can run on the Raspberry Pi (4 or higher), based on the JetBrains and Stack Overflow surveys and Top IDE index. This list includes ‘true’ IDEs — single programs that unify project editing, debugging, and versioning at least.
| Name | Support |
|---|---|
| IntelliJ IDEA[1,2] | Linux, macOS, Windows |
| PyCharm CE[1,3] | Linux, macOS, Windows |
| Eclipse IDE[1,2] | Linux, macOS, Windows |
| Visual Studio Code[2] | Linux, macOS, Windows |
Note: Running these IDEs on *BSD or non-Debian systems can be challenging due to limited support and potential compatibility issues, often requiring workarounds or manual setups.
VSCode is officially distributed via the Raspberry Pi OS APT repository, in both 32-bit and 64-bit variants.
sudo apt update
sudo apt install code
https://code.visualstudio.com/docs/setup/raspberry-pi
A Raspberry Pi will be used for the remainder of the demonstration. Refer to the official VS Code documentation for instructions tailored to other operating systems.



From top to bottom the icons are:
Let’s open a simple project (demo_01.py on GitHub) to demonstrate each element of the interface.

In the Explorer Primary Side Bar, you should see the following three major sections by default:

Since this is our first Python file opened, VS Code prompts us to install the recommended Python extensions. Let’s dismiss that notification to explore the default operation.

First thing you should notice is that your code is syntax highlighted and on the right you will see a Minimap, which gives you a high-level overview of your source code.
When you type more code, VS Code offers autocomplete suggestions, including references to your own code, such as variables and functions. Since you’ve edited the file, you should also see a circle with the number one above the Explorer Activity button to indicate you have one unsaved file.
To provide a richer experience, we can install the Python extensions to add IntelliSense (Pylance), debugging (Python Debugger), formatting, linting, code navigation, refactoring, variable explorer, and more.
(I’m also going to install the Vim extension to avoid mistakes.)
Clear the search field, and you should see the new extensions under the Installed section. We’ll explore more extensions near the end of the presentation.
Return to the Explorer tab and select the demo Python file. With the Python extensions installed, a new ‘play’ icon will be available at the top-right corner of the Editor. Click it to run the current file.
Best practice for Python projects is to use a virtual environment and store your code in a repository.
With the Python extension installed, we can use VS Code to create a virtual environment.
CTRL + SHIFT + P.

/bin/python and /usr/bin/python/, and these are symbolic links to the Python included in the installation.)

Likewise, we can use VS Code to initialize a git repository in our project.

If you haven’t already configured Git on your system, you will need to run the following commands in a terminal (as the user of Visual Studio Code, not root).
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
Now that we have initialized a repository, notice that the Primary Side Bar is divided into two major sections: Source Control and Source Control Graph.
The Source Control section has different subsections depending on the state of your commit.
Changes: shows the files that are untracked or modified.
When you select a file, your file will be open in a side-by-side diff view, with the previous committed version of the file on the left, if any, and the changed version on the right. (Only the right-hand side is editable.) Green highlighted lines are inserts and red are deletes.

To the right of the filename, that’s selected in the Primary Side Bar, there are four icons (from left to right):
Click the Stage Changes (plus symbol) next to your project file. This is equivalent to git add filename.
Notice that the file appears in the new Staged Changes section.
Staged Changes: shows the file that are staged and ready to commit. (This section only appears when there are staged files.)
Once you have one or more files staged, you can commit them to your repository. Write a short descriptive commit message in the Message text box and then click Commit.
Your commit will now appear under the Source Control Graph. When you click on it, you’ll see another side-by-side of all the patches.
Tip: I like to keep each commit focused on a single, cohesive change,
so I always review the diff of each file, before staging them, in case
I need to remove any unrelated code. (Once you stage a file, you can
no longer see the diff view.) You can also stage a subset of the
files and commit them and repeat for the others as many times as
necessary.
Let’s make another change that we can commit to our repository:
Observe there are now blue and green bar(s) and red triangle(s) along the line numbers. The blue bars span the lines that have been changed; green bars are those lines that are new; and, the red triangles indicate where code was deleted.
Clicking on one of those bars or triangles will open a floating horizontal diff showing you the changes. Click the Close (X) icon in the upper-right of the diff view to close it.
Switch to the Source Control activity and click on the file you just edited. Notice that the Minimap shows the general locations of your changes and the diff view shows the changes.
Click the Stage Changes button, type your commit message, and then click the Commit button. Rinse and repeat.
The Python Debugger extension leverages debugpy and provides you graphical interaction to set breakpoints, step through code, inspect variables, and more.
To engage the debugger, you need to set a breakpoint in your code first. Hover over the left side of the line number column and you should notice a dark red dot. Click on any line with code, except a function definition, and a bright red dot will appear. (The debugger will stop when a function is loaded but not during its execution.) Let’s set one on the line with, if operation == "+":
Before running the debugger, let’s also add a global class and a return value to the welcome_message() function. Notice how the breakpoint (red dot) stays with the statement where we set it.
class Foo:
x = 5.0002
def welcome_message():
"""Displays a welcome message."""
print("Welcome to the VS Code Python Demo!")
print("Here, you'll see some basic Python functionality.")
return 0
Click the chevron to the right of the ‘play’ button, and then click Python Debugger: Debug Python File. (We aren’t going to use the Run and Debug button in Primary Side Bar because it has more steps.) Code execution will pause on the line with the breakpoint.
When the debugger is started, the Primary Side Bar changes to include three sections:

Note that you can set additional breakpoints while debugging your code.
Once the breakpoint is hit and execution is paused, expand the Locals and you should see the three variables and the values you’ve entered.
Click the + (Add Expression) button to the right of the Watch section header. Type num1 into the Expression to watch text box. You should see that its value is identical to num1 in the Variables -> Locals section.
Repeat those actions and observe the results for the following statements:
num1 + num2num1 - num2num1 * num2num1 / num2num1 % num2Try the following and observe:
welcome_message()Foo.x()
If you make a mistake or want to remove one of the watch statements, click the X (Remove Expression) icon.
At the top-centre of the active file in the Editor, you’ll see a floating toolbar that contain the following icons (from left to right):
The Extension Marketplace contains about 60,000 extensions.
In addition to the required Python extensions, I’ve curated a lists of recommended and optional extensions that I find useful.
Thank you for your time, attention, and interest in this presentation. Your engagement and feedback are greatly appreciated.
You should now have a better understanding of:
I’m happy to address any questions or discuss further insights.