How to Run Jupyter Notebook in VSCode – A Complete Step-by-Step Guide

Running Jupyter Notebook in Visual Studio Code (VSCode) offers the best of both worlds: the interactive nature of notebooks combined with the power of a full-featured code editor. Whether you’re a data scientist, machine learning engineer, or Python developer, integrating Jupyter into VSCode can greatly enhance your workflow. In this comprehensive guide, we’ll show you exactly how to run Jupyter Notebooks in VSCode, from installation to running your first cell, with all the customization tips you need for an efficient setup.

Why Use Jupyter Notebooks in VSCode

Before jumping into the how-to, it’s worth exploring why you might want to use Jupyter in VSCode instead of the traditional web-based interface.

  • Unified Environment: Instead of switching between browser tabs and text editors, you can write scripts and run notebooks side by side.
  • Rich Editing Features: Leverage VSCode’s IntelliSense, Git integration, version control, and debugger inside notebooks.
  • Lightweight & Fast: VSCode is lighter than heavy IDEs and faster to launch compared to Jupyter Lab or Jupyter Notebook servers.
  • Better Extension Ecosystem: Use tools like Python formatting, linters, and Docker integration within the same interface.
  • Remote Development Support: Run and manage notebooks in remote servers or containers using VSCode’s SSH or DevContainer features.

With those advantages in mind, let’s walk through the process of setting it up and running your first notebook.

Step 1: Install Visual Studio Code

If you haven’t already, download and install Visual Studio Code:

  • Go to the official website: https://code.visualstudio.com
  • Choose the right installer for your OS (Windows, macOS, or Linux)
  • Follow the setup instructions to complete the installation

Once installed, launch VSCode to continue with the next steps.

Step 2: Install the Python Extension

The Python extension is crucial for running Jupyter Notebooks in VSCode.

  • Click the Extensions icon on the sidebar or press Ctrl+Shift+X
  • In the search box, type Python
  • Find the extension by Microsoft (over 50 million downloads)
  • Click “Install”

This extension includes support for running Python code, Jupyter Notebooks, code linting, IntelliSense, and more.

Step 3: Install the Jupyter Extension

Although the Python extension now includes Jupyter support by default, it’s best to install the Jupyter extension explicitly.

  • In the Extensions panel, search for Jupyter
  • Click “Install” on the Jupyter extension by Microsoft

This extension enables the ability to open .ipynb files directly, run code cells, display visualizations inline, and even manage Jupyter kernels.

Step 4: Install Python and Jupyter on Your System

To actually run notebooks, you need Python and the jupyter package installed on your machine.

If you haven’t installed Python:

Then, open a terminal or command prompt and install Jupyter:

pip install notebook

Alternatively, you can install it using Anaconda or Miniconda:

conda install jupyter

This ensures your machine has everything needed to launch and execute Jupyter notebooks.

Step 5: Create or Open a Jupyter Notebook

Once all extensions and dependencies are installed:

  • Open VSCode
  • Use File > Open Folder to open a working directory
  • To create a new notebook, click the “New File” icon and save it with a .ipynb extension
  • Or right-click inside the Explorer and choose New File, then name it like example.ipynb
  • You’ll now see a Jupyter-style interface embedded directly in VSCode

Alternatively, you can open an existing .ipynb file just like any other file.

Step 6: Select Python Interpreter or Kernel

When you open a notebook, VSCode may prompt you to select a kernel. This is the Python interpreter that will run your notebook code.

  • At the top right, click on the “Select Kernel” dropdown
  • VSCode will list available Python environments (venv, conda, system)
  • Choose the one where Jupyter is installed
  • You can also create a new environment with:
python -m venv .venv
source .venv/bin/activate # macOS/Linux
.venv\Scripts\activate # Windows
pip install ipykernel jupyter

Then add the new environment as a kernel using:

python -m ipykernel install --user --name=myenv --display-name "Python (myenv)"

Now the environment will be selectable inside VSCode.

Step 7: Run Your First Notebook Cell

To run code inside the notebook:

  • Click inside a cell
  • Press Shift + Enter to execute it
  • The output will appear right below the cell
  • Use Ctrl + Enter to run the cell without moving to the next one

You can also click the Run arrow button on the left of the cell.

Try running this to test your setup:

import sys
print("Running Python version:", sys.version)

You should see output like:

Running Python version: 3.11.6 (default, Nov 1 2023, 15:20:23)

Step 8: Add Markdown and Headings

VSCode supports rich Markdown inside notebooks. To add a markdown cell:

  • Click the + button at the top
  • Click the dropdown in the new cell and change it from “Code” to “Markdown”
  • Add your notes, formulas, or headers like this:
# Section Title
## Subsection
**Bold text**, *italic text*, and inline `code`

Press Shift+Enter to render the Markdown.

Step 9: Visualizations and Data Science Support

VSCode fully supports inline visualizations. For example, try running:

import matplotlib.pyplot as plt

x = [1, 2, 3, 4]
y = [10, 20, 25, 30]

plt.plot(x, y)
plt.title("Sample Plot")
plt.show()

You’ll see the graph rendered directly in the output cell. You can also use Seaborn, Plotly, Bokeh, or Pandas visualizations the same way.

Step 10: Use Git and Version Control

One of VSCode’s major advantages is built-in version control.

  • Use the Source Control tab on the sidebar
  • Initialize a Git repository (git init)
  • Add your notebook and commit changes
  • VSCode will track .ipynb diffs in a visual-friendly format

This is helpful when collaborating with teams or maintaining reproducible experiments.

Step 11: Run Notebooks in a Remote Environment

If you have a remote server or virtual machine with Python and Jupyter installed, you can:

  • Use VSCode’s Remote – SSH extension to connect to the server
  • Use Jupyter Server URI settings to point to a remote notebook server
  • Or run Jupyter in a Docker container and connect to it from VSCode

These advanced configurations allow you to keep your local machine lightweight and run heavy tasks on a powerful server.

Step 12: Customize Your Notebook Experience

You can fine-tune your notebook experience with VSCode settings:

  • jupyter.interactiveWindowMode: Choose between “perFile” or “single”
  • jupyter.askForKernelRestart: Toggle confirmation dialogs
  • python.formatting.provider: Use black, autopep8, or yapf
  • Enable linting for real-time feedback using pylint or flake8

Use Cmd+, or Ctrl+, to open settings and search for “Jupyter” or “Python” to explore options.

Conclusion

VSCode provides an excellent environment for running and managing Jupyter Notebooks. From rich editing tools and kernel selection to Git integration and remote execution, it delivers a smooth and powerful notebook experience. By following the steps in this guide, you can install, configure, and run notebooks inside VSCode efficiently.

Not only does this setup streamline your workflow, but it also helps you leverage the strengths of both notebook-based interactivity and full IDE features. If you’re a data scientist, machine learning practitioner, or Python developer, mastering Jupyter in VSCode will take your productivity to the next level.

Leave a Comment