Skip to content

How to use Jupyter Notebook in VS Code

The Problem

When I tried to run Jupyter Notebook in VS Code for the first time, I couldn’t figure out where to start. I saw people online using .ipynb files with interactive cells and visualizations, but my VS Code just showed me a plain text editor.

I asked around: “How do people get Jupyter in VS Code?”

The answers were confusing. Some said install JupyterLab. Others said use Anaconda. A few mentioned VS Code extensions. I wasn’t sure if I needed a separate Jupyter installation or if VS Code could handle it natively.

Environment

  • VS Code (latest version)
  • Python 3.11
  • macOS (same process works on Windows/Linux)
  • No prior Jupyter installation

What happened?

I wanted Jupyter’s interactive computing without leaving VS Code. I like having one IDE for everything—coding, debugging, Git, and now data exploration. Switching between VS Code for scripts and browser-based Jupyter Notebook felt inefficient.

Here’s what I tried:

First attempt: Installing Jupyter separately

Terminal window
pip install jupyter

Then I ran:

Terminal window
jupyter notebook

This opened Jupyter in my browser. It worked, but this wasn’t what I wanted. I wanted Jupyter inside VS Code, not a separate browser tab.

Second attempt: Creating .ipynb file in VS Code

I created a file called notebook.ipynb in VS Code. But it just showed me raw JSON:

notebook.ipynb
{
"cells": [],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

No interactive cells. No run button. Just JSON.

The problem was clear: VS Code didn’t know how to handle .ipynb files yet.

How to solve it?

The solution is the official VS Code Jupyter extension. Here’s what worked:

Step 1: Install the Jupyter extension

I opened VS Code and went to the Extensions panel (Ctrl+Shift+X or Cmd+Shift+X). I searched for “Jupyter” and found the official extension by Microsoft.

Alternatively, you can install from command line:

Terminal window
code --install-extension ms-toolsai.jupyter

This also auto-installs the Python extension as a dependency, which you need for kernel support.

Step 2: Create a new Jupyter Notebook

Now when I created a .ipynb file, VS Code recognized it immediately.

I went to Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and typed “Jupyter: Create New Jupyter Notebook”. VS Code created a new notebook file with an interactive interface.

I could see:

  • Code cells with run buttons
  • A kernel selector at the top-right
  • Cell type indicators (Code vs Markdown)

Step 3: Select a Python kernel

The first time I tried to run a cell, VS Code asked me to select a kernel. A kernel is the computational engine that executes your code.

I saw options like:

  • Python 3 (system Python)
  • Virtual environments I had created
  • Conda environments (if you use Anaconda)

I selected my Python 3 environment and waited for the kernel to initialize. This takes longer on first run while it installs IPython kernel support.

Step 4: Run cells

Now I could write code in cells and execute them:

example.ipynb
import pandas as pd
import numpy as np
# Create sample data
data = pd.DataFrame({
'x': np.linspace(0, 10, 100),
'y': np.sin(np.linspace(0, 10, 100))
})
data.head()

I pressed Shift+Enter to run the cell. The output appeared right below the code.

For visualizations:

import matplotlib.pyplot as plt
plt.figure(figsize=(10, 6))
plt.plot(data['x'], data['y'])
plt.title('Sine Wave')
plt.show()

The plot rendered inline in VS Code. No browser needed.

Step 5: Use Markdown cells

I needed to document my analysis. I changed a cell type to Markdown (dropdown in cell toolbar) and wrote:

## Data Analysis
This notebook explores the sine wave function.

Running the Markdown cell rendered formatted text instead of code execution.

Why this works

The VS Code Jupyter extension connects VS Code’s editing interface to an IPython kernel running in the background. The extension handles:

  • Cell-based code execution
  • Output rendering (text, plots, HTML)
  • Kernel management
  • Interactive features like variable explorer

You don’t need a separate Jupyter installation because the extension includes the necessary integration pieces. You just need Python itself.

Advanced features I discovered

After the basic setup, I found useful features:

Variable Explorer

When I run cells, VS Code tracks all variables in my session. I can open the Variable Explorer panel to inspect dataframes, arrays, and objects without printing them.

IntelliSense in notebooks

VS Code’s autocomplete works in Jupyter cells. When I type data., I see all DataFrame methods and attributes. Function signatures appear inline.

Git integration

I can version control .ipynb files with Git. VS Code’s diff view shows changes in a readable format (not raw JSON diffs). This is much better than browser-based Jupyter.

Debugging

I can set breakpoints in Jupyter cells and use VS Code’s debugger. Step through code, inspect variables, use watch expressions—all within a notebook workflow.

Common issues I ran into

Issue 1: No kernel appears in selector

When I opened a notebook, the kernel selector was empty.

The problem was my virtual environment didn’t have ipykernel installed. I fixed it with:

Terminal window
# Activate my environment
source .venv/bin/activate
# Install ipykernel
pip install ipykernel
# Register the kernel
python -m ipykernel install --user --name=.venv

Now the environment appeared in VS Code’s kernel picker.

Issue 2: Kernel fails to start

Sometimes I got this error:

Error: Jupyter server process failed to start

The issue was usually Python path confusion. VS Code couldn’t find the Python executable for my selected environment.

I fixed this by:

  1. Opening VS Code’s Python extension settings
  2. Checking that the correct Python interpreter was selected
  3. Reloading VS Code window (Developer: Reload Window from Command Palette)

Issue 3: Extension doesn’t recognize .ipynb files

If VS Code still shows raw JSON instead of an interactive notebook, the Jupyter extension might not be loaded.

I checked:

  1. Extensions panel—confirm Jupyter extension is installed and enabled
  2. Reloaded VS Code
  3. If that failed, I reinstalled the extension

VS Code Jupyter vs. JupyterLab

After using both, I can see when each makes sense:

Use VS Code Jupyter when:

  • You need full IDE features (debugging, refactoring, IntelliSense)
  • Your project mixes scripts and notebooks
  • You want Git integration
  • You prefer VS Code’s keyboard shortcuts
  • You like having one tool for everything

Use JupyterLab when:

  • You’re collaborating with non-VS Code users
  • You need advanced file browser features for large projects
  • You prefer a browser-based interface
  • Your team standardizes on JupyterLab

For solo work or mixed projects, I prefer VS Code Jupyter. The workflow is smoother when I can switch between notebooks and Python scripts without changing context.

The architecture

Here’s how the pieces fit together:

┌─────────────┐
│ VS Code │
│ (Editor) │
└──────┬──────┘
┌─────────────────┐
│ Jupyter │
│ Extension │
└────────┬────────┘
┌─────────────────┐
│ IPython Kernel │◄──── Python Environment
└─────────────────┘ (venv, conda, system)
┌─────────────────┐
│ .ipynb File │
│ (Cells) │
└─────────────────┘

The extension acts as a bridge. VS Code handles the UI, the IPython kernel executes code, and your notebook file stores the cells and outputs.

Summary

In this post, I showed how to get Jupyter Notebook running in VS Code using the official extension. The key point is you don’t need a separate Jupyter installation—just the VS Code extension and Python.

The setup takes five minutes:

  1. Install the Jupyter extension
  2. Create a .ipynb file
  3. Select your Python kernel
  4. Start running cells

You get Jupyter’s interactivity with VS Code’s editing features, debugging, and Git integration. For most Python work, this combination beats switching between tools.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments