VS Code has become the default editor for Python development, and its native Jupyter notebook support means you no longer need to run a separate Jupyter server in your browser to work with .ipynb files. Everything — cell execution, kernel selection, variable inspection, plot rendering — happens inside VS Code itself. This guide covers the complete setup from scratch, the key workflows you’ll use daily, and the fixes for the issues that catch most people out on first setup.
Why Run Jupyter Notebooks in VS Code
The traditional Jupyter workflow requires launching a server from the terminal, opening a browser tab, and navigating a separate interface. VS Code’s Jupyter integration eliminates all of that. Notebooks open directly as files, the full VS Code feature set (IntelliSense, git integration, extensions, themes, keybindings) applies inside notebook cells, and you can switch between .py scripts and .ipynb notebooks without leaving the editor. For data science and ML work where you’re constantly moving between exploration in notebooks and production code in scripts, this unified environment is a significant quality-of-life improvement.
What You Need to Install
Three things are required before Jupyter notebooks work in VS Code: VS Code itself, the Python and Jupyter extensions from Microsoft, and a Python environment with the ipykernel package installed. The extensions handle the notebook interface; ipykernel is the bridge that lets VS Code communicate with the Python process running your code.
If you don’t have VS Code, download it from code.visualstudio.com. Once installed, open the Extensions panel (Ctrl+Shift+X on Windows/Linux, Cmd+Shift+X on Mac) and search for “Python”. Install the Python extension from Microsoft — this also pulls in Pylance for IntelliSense. Then search for “Jupyter” and install the Jupyter extension, also from Microsoft. Both are free.
For the Python environment, you have two main options. If you already have Python installed, install ipykernel into your environment with pip. If you’re starting fresh, Anaconda or Miniconda is the easier route — both come with Jupyter pre-installed and manage scientific Python packages cleanly. Either approach works; the choice depends on whether you prefer a minimal setup or a batteries-included data science environment.
Opening and Creating Notebooks
To open an existing .ipynb file, use File → Open File and select it directly — VS Code recognises the extension and opens it in the notebook interface automatically. To create a new notebook, open the Command Palette (Ctrl+Shift+P) and run “Create: New Jupyter Notebook”. VS Code creates a new untitled .ipynb file with one empty code cell ready to use.
You can also open a notebook from the terminal by navigating to your project folder and running code notebook.ipynb, or by opening a folder in VS Code and clicking any .ipynb file in the Explorer panel.
Selecting the Python Kernel
The kernel is the Python process that executes your notebook cells. When you first open or create a notebook, VS Code will prompt you to select a kernel — look for the kernel picker in the top right corner of the notebook interface. Click it to see all available Python environments on your machine: your system Python, any virtual environments, Conda environments, and so on.
Select the environment where you have your project’s packages installed. If you’re working on a data science project with pandas, numpy, and scikit-learn, select the environment where those are installed. If the environment you want doesn’t appear, it may be because ipykernel is not installed there — run pip install ipykernel inside that environment and reload VS Code.
Figure 1 — Jupyter in VS Code: setup checklist
Running Cells and Keyboard Shortcuts
Once a kernel is selected, running cells works the same way as in the browser Jupyter interface. Shift+Enter runs the current cell and moves to the next. Ctrl+Enter runs the current cell and stays on it. Alt+Enter runs the current cell and inserts a new one below. The run button in the cell toolbar and the Run All button at the top of the notebook also work as expected.
A few VS Code-specific shortcuts that differ from browser Jupyter: Escape puts a cell in command mode (where you can navigate between cells with arrow keys and add/delete cells); Enter puts it back into edit mode. In command mode, A inserts a cell above and B inserts one below — the same as browser Jupyter. M converts a cell to Markdown and Y converts it back to code.
The command palette (Ctrl+Shift+P) is particularly useful in notebooks — search “Jupyter” to see all available notebook commands, including ones that aren’t bound to keyboard shortcuts by default, like “Restart Kernel and Run All Cells” and “Clear All Outputs”.
Working with Virtual Environments
For any serious project, running notebooks in a virtual environment rather than your system Python is strongly recommended. It keeps project dependencies isolated and prevents package version conflicts between projects. Create a virtual environment in your project folder, install ipykernel into it, and it will appear in VS Code’s kernel picker automatically.
With Conda, create an environment and activate it, then install ipykernel. VS Code detects Conda environments and lists them in the kernel picker — look for the environment name prefixed with “Python (conda)”. If you’re using pyenv, the same applies: create an environment, install ipykernel, and it shows up in the picker.
One important VS Code behaviour: when you open a folder that contains a virtual environment named .venv or env, VS Code automatically selects that environment for new notebooks. This is convenient for single-project setups but can surprise you on multi-project workspaces — always check the kernel picker to confirm which environment is active before running cells.
Variables, Plots and the Data Viewer
VS Code’s Jupyter integration adds features not available in the browser interface. The Variables panel (accessible from the notebook toolbar) shows all variables currently in scope with their type, size, and value — useful for debugging without adding print statements. Click any pandas DataFrame in the Variables panel to open the Data Viewer, a sortable, filterable table view of the data. For large DataFrames this is significantly faster than scrolling through notebook output.
Plots render inline below cells just as in browser Jupyter, but VS Code also shows them in a dedicated Plots panel that keeps a history of all plots generated in the session. This means you can refer back to an earlier plot without re-running the cell that generated it, which is useful when you’re iterating on visualisations and want to compare outputs.
Running .ipynb Files from the Command Line
Sometimes you want to run a notebook non-interactively — in a CI pipeline, as a scheduled job, or to regenerate output without opening VS Code. The nbconvert tool handles this: install it with pip and run it with the execute flag and the notebook path. This executes all cells in order and writes the output back to the file or to a new output file. The results are identical to running the notebook interactively, making nbconvert the standard way to automate notebook execution outside of an editor.
Common Issues and Fixes
A few problems come up consistently when setting up Jupyter in VS Code for the first time:
- Kernel not found or no kernels listed: ipykernel is not installed in the target environment. Activate the environment in a terminal and run
pip install ipykernel, then reload VS Code and check the kernel picker again. - Module not found errors when running cells: The selected kernel uses a different Python environment from where your packages are installed. Check the kernel picker — the environment name shown there tells you which Python is being used. Switch to the correct one.
- Notebook opens as plain JSON text instead of notebook UI: VS Code is not recognising the file as a notebook. Check that the Jupyter extension is installed and enabled. Sometimes disabling and re-enabling the extension fixes this.
- Plots not displaying inline: Add
%matplotlib inlineas the first cell, or set the backend explicitly withimport matplotlib; matplotlib.use('Agg')if running in a headless environment. - Slow first cell execution: Normal — the kernel takes a few seconds to start on first use. Subsequent cells in the same session run immediately.
Frequently Asked Questions
- Do I still need to install Jupyter separately to use notebooks in VS Code?
- No. The VS Code Jupyter extension handles everything. You only need ipykernel installed in your Python environment — the full Jupyter package is not required for VS Code notebook execution.
- Can I use VS Code notebooks with Anaconda?
- Yes. Anaconda environments appear automatically in the VS Code kernel picker. Create a Conda environment, activate it, and VS Code will list it. No additional configuration needed.
- Does VS Code support all Jupyter notebook features?
- The vast majority yes — cell execution, Markdown rendering, plots, widgets, magic commands, and kernel restart all work. A small number of advanced Jupyter Lab features (custom extensions, the full Lab interface) are not replicated, but for standard data science work nothing is missing.
- Can I run notebooks on a remote server from VS Code?
- Yes. The VS Code Remote — SSH extension lets you connect to a remote machine and run notebooks there, with the notebook interface still in your local VS Code window. The Remote — Tunnels extension extends this to any internet-accessible machine without requiring direct SSH access.
- How do I convert a notebook to a Python script?
- Right-click the notebook tab and choose “Export” → “Python Script”, or run
jupyter nbconvert --to script notebook.ipynbfrom the terminal. VS Code also lets you open any .ipynb file as a plain Python file via the “Open as Text” option if you just want to inspect the raw JSON.
Last updated: October 2026