Skip to content

Visual Studio Code Setup

VS Code is an open-source editor by Microsoft. Since its release in 2015, VS Code has become incredibly popular. See, for example, the 2024 Developer Survey by Stack Overflow.

VS Code has support for many languages, including Python, Java, C/C++, JavaScript, and more. This page explains how to install and configure VS Code for Python in CS 149.

Note

If you are on a CS lab machine, Python and VS Code are already installed. Skip to Step 3.

Step 1: Install Python

Thonny comes with Python built-in, which is ideal for beginners. But generally, you need to install Python separately.

If you haven't done this previously, visit python.org. Download the installer for your operating system, and run the installer. To verify the installation was successful, open a Terminal and type either python3 --version (on macOS) or py --version (on Windows). Your version number might be newer than the images below.

Tip

When installing on Windows, check the box for "Add python.exe to PATH".

Figure 1: Running the Python Installer
Python Installer Windows

Figure 2: Running Python in the Terminal
Terminal: java -version

Step 2: Install VS Code

Visit code.visualstudio.com and click the Download button.

  • On macOS, drag the app to the Applications folder. Additional details are available here.
  • On Windows, run the installer and follow the steps. Additional details are available here.

If you are running VS Code for the first time, you should see the Welcome Page. If you have used VS Code in the past, you will likely see your previous files.

Figure 3: VS Code's Welcome Page
Welcome - Visual Studio Code

Step 3: Install Extensions

Extensions add new features and languages to VS Code. Developers can publish extensions via the Marketplace.

  1. Click the Extensions icon in the Activity Bar (on the left).
    Extensions (Ctrl+Shift+X)
  2. Search for (by name) and install the following extensions:

Note: The Python extension also installs Pylance, Python Debugger and Python Environments. In the end, you should have the following six extensions installed:

Figure 4: List of Installed Extensions
VS Code extensions screenshot

Danger

For CS 149, we strongly discourage the use of integrated AI tools. Uninstall extensions like GitHub Copilot, ChatGPT, etc. You might use these tools in later courses and in your career. But for now, AI tools will likely interfere with your learning. (For example, see this PsyPost article from September 2025.)

Step 4: Your CS149 Folder

If you followed our advice at the beginning of the semester, you should a CS149 containing all your work for the course. Open this folder in VS Code by going to the File menu (at the top) and clicking "Open Folder…" The folder contents (on the left) might look like this:

CS149 folder in VS Code

Having a folder open in VS Code provides additional features that are not active when simply opening a file. For one, the Search feature (magnifying glass icon on the left) will allow you to search all of your CS 149 files.

Step 5: Virtual Environment

After opening your CS149 folder, make sure your "virtual environment" (venv) is activated. First, open a Python file to activate the Python extension. Then, click the Python version number in the lower-right corner of the window:

Select interpreter button of VS Code

Note

If you don't see (.venv) after the version number, click the "Create Virtual Environment…" option. Select "Venv" and then click the Python interpreter you installed previously. This process will create a .venv folder under your CS149 folder so you can install packages.

Before moving on to the next step, make sure that your virtual environment is really activated. Click the trash icon () on the top or right side of the terminal to delete all previous terminals. Then open a brand new terminal window. You should see the text (.venv) at the beginning of the command line. If not, ask for help from an instructor or TA.

Note

If you created a new Virtual Environment, you will need to install packages. Previously, we had you install these packages via Thonny. Run the following command in the terminal:

pip install ruff pytest-cov

Step 6: Workspace Settings

VS Code has thousands of settings that you can customize. The following settings are recommended for CS 149. You are welcome to change any of these and add your own.

  1. Press F1 to open the command pallette.
  2. Type work json and press Enter.
    • This will open a file named settings.json.
  3. Paste the following settings between the curly braces:
        "breadcrumbs.enabled": false,
        "editor.minimap.enabled": false,
        "editor.scrollBeyondLastLine": false,
        "files.exclude": {
            "**/__pycache__": true,
            "**/.pytest_cache": true,
            "**/.coverage": true,
            "**/.ruff_cache": true,
        },
        "files.insertFinalNewline": true,
        "files.trimFinalNewlines": true,
        "files.trimTrailingWhitespace": true,
        "python.testing.pytestArgs": [
            ".",
        ],
        "python.testing.pytestEnabled": true,
        "python.testing.unittestEnabled": false,
        "terminal.integrated.allowChords": false,
        "workbench.tree.indent": 16,
    
  4. Save and close the settings.json file.

At this point, you can open any folder in VS code and start programming. For this course, we recommend that you always open your top-level CS149 folder.

Going Further (optional)

The official tutorial by Microsoft is available here: Getting Started with Python in VS Code (15 articles). You don't need to read the tutorial. We will teach you what you need to know.