# How to Run Jupyter Notebooks in VS Code for the AI For Beginners Curriculum

> Learn to run Jupyter notebooks in VS Code for the AI For Beginners curriculum. Clone the repo, create the Conda environment, and select the interpreter to run AI lessons directly in the editor.

- Repository: [Microsoft/AI-For-Beginners](https://github.com/microsoft/AI-For-Beginners)
- Tags: how-to-guide
- Published: 2026-08-01

---

**You can run the Microsoft AI For Beginners curriculum notebooks in VS Code by cloning the repository, creating the Conda environment from [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml), and selecting the `ai4beg` interpreter to execute cells directly in the editor.**

The Microsoft AI For Beginners curriculum is structured as a collection of Jupyter notebooks designed to teach core AI concepts through interactive code examples. VS Code serves as the recommended integrated development environment because it natively supports Python notebooks, automatically detects Conda environments defined in the repository, and allows you to edit and execute code without leaving the editor. This guide walks through the exact workflow documented in [`lessons/0-course-setup/how-to-run.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/0-course-setup/how-to-run.md) and [`AGENTS.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/AGENTS.md) to configure your local environment.

## Prerequisites

Before running notebooks, ensure you have **VS Code** and **Conda** (Anaconda or Miniconda) installed on your system. The curriculum dependencies are pinned in [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) at the repository root, specifying exact versions of TensorFlow, PyTorch, Keras, OpenCV, and other machine learning libraries required for reproducible execution.

## Step-by-Step Setup Process

### Clone the Repository and Create the Conda Environment

Start by cloning the repository and creating the isolated environment named `ai4beg`. According to the setup instructions in [`lessons/0-course-setup/how-to-run.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/0-course-setup/how-to-run.md) (lines 11-16), run the following commands:

```bash
git clone https://github.com/microsoft/ai-for-beginners
cd ai-for-beginners
conda env create --name ai4beg --file environment.yml
conda activate ai4beg

```

This creates a dedicated environment containing all necessary packages, preventing conflicts with your system Python installation.

### Open the Repository in VS Code

Launch VS Code from the repository root to ensure the workspace context is properly established:

```bash
code .

```

Upon opening the folder, VS Code will detect the Python project structure. As noted in [`lessons/0-course-setup/how-to-run.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/0-course-setup/how-to-run.md) (lines 20-22), the editor will prompt you to install the **Python extension** if it is not already present. Install this extension to enable notebook support and interpreter management.

### Select the Conda Interpreter

The Python extension automatically discovers the `ai4beg` environment created in the previous step. You must explicitly select this interpreter to ensure notebook kernels run with the correct packages:

1. Open the Command Palette (**⇧ ⌘ P** on macOS or **Ctrl+Shift+P** on Windows/Linux)
2. Type "Python: Select Interpreter"
3. Choose the `ai4beg` environment from the dropdown list

This step binds VS Code to the Conda environment, ensuring that imports like `import tensorflow` or `import torch` resolve to the versions specified in [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml).

### Open and Execute Notebooks

Navigate to any lesson directory under `lessons/` and open a `.ipynb` file. For example, open `lessons/3-NeuralNetworks/03-Perceptron/Perceptron.ipynb` to view the notebook UI within VS Code.

To execute code:

- Click on a code cell
- Press **Shift + Enter** to run the cell in the selected kernel
- View outputs (including plots and DataFrames) directly beneath the cell

You can step through the curriculum at your own pace, modifying parameters and observing results in real time.

## VS Code Jupyter Features

Beyond basic cell execution, VS Code provides enhanced notebook functionality through the **Jupyter** extension. As implemented in the repository architecture described in [`AGENTS.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/AGENTS.md) (lines 68-73), these features include:

- **Variable Explorer**: Inspect Python variables and their current values during execution
- **Interactive Window**: Convert code cells to an interactive Python session for experimentation
- **Jupyter Lab Interface**: Access the full Jupyter Lab UI within VS Code via the Jupyter extension, providing a file explorer and advanced markdown rendering
- **Integrated Debugging**: Set breakpoints in notebook cells and step through code execution

## Summary

- The AI For Beginners curriculum uses Jupyter notebooks stored in the `lessons/` directory, such as `lessons/3-NeuralNetworks/03-Perceptron/Perceptron.ipynb`.
- Create the `ai4beg` Conda environment using [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) to install pinned dependency versions of TensorFlow, PyTorch, and other libraries.
- VS Code automatically detects the environment when you select the interpreter via **Python: Select Interpreter**.
- Run cells using **Shift + Enter** to execute code directly in the editor with outputs rendered below each cell.
- The workflow is documented in [`lessons/0-course-setup/how-to-run.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/0-course-setup/how-to-run.md) and supported by the architecture outlined in [`AGENTS.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/AGENTS.md).

## Frequently Asked Questions

### Do I need to install Jupyter separately for VS Code?

No. When you install the Python extension in VS Code, it automatically installs the Jupyter extension as a dependency. The notebook interface renders natively within VS Code without requiring a separate Jupyter installation or browser window, though the underlying Jupyter protocol still operates through the selected Conda kernel.

### Can I use a virtual environment instead of Conda?

While the curriculum officially supports Conda as documented in [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml), you can technically use `venv` or `virtualenv` if you manually install the packages listed in that file. However, using the Conda environment named `ai4beg` ensures exact version compatibility with the curriculum's tested configuration and is the recommended approach according to the setup guide.

### How do I resolve "Kernel not found" errors in VS Code?

If VS Code cannot locate the `ai4beg` kernel, first ensure the environment is activated in your terminal (`conda activate ai4beg`). Then restart VS Code and reselect the interpreter via **⇧ ⌘ P** → "Python: Select Interpreter" → `ai4beg`. If the issue persists, run `python -m ipykernel install --user --name=ai4beg` within the activated environment to explicitly register the kernel with Jupyter.

### Is it possible to run these notebooks in JupyterLab instead of VS Code?

Yes. The curriculum notebooks are standard `.ipynb` files compatible with any Jupyter client. You can launch JupyterLab from the activated `ai4beg` environment by running `jupyter lab` in the terminal. However, the curriculum authors recommend VS Code for its integrated editing and debugging features, as highlighted in the repository's agent documentation.