Jupyter Notebooks have become an essential tool for data scientists, analysts, and anyone involved in exploratory data analysis or machine learning. While there’s a standalone web-based application for running Jupyter Notebooks, integrating this functionality directly into Visual Studio Code (VS Code) offers many additional benefits, such as an improved code editor, integration with other languages, and a unified development environment. In this post, In this blog post, I am excited to share my journey of setting up Jupyter Notebooks in VS Code.
Step 1: Install the Required Extensions
First, you need to install two key extensions for VS Code:
-
Python Extension: This is essential for Python development in VS Code. It provides features such as IntelliSense, linting, debugging, and more.
-
Jupyter Extension: This extension enables you to run Jupyter Notebooks inside VS Code. It allows you to create, view, and manage notebook files, and execute code cells just like in a standalone Jupyter environment.
Step 2: Install UV
Before proceeding with the installation of Jupyter’s kernel, ensure that the UV environment is set up. You can install UV, a powerful tool for project management in Python, using Homebrew with the following command:
brew install uv
Step 3: Install a Kernel for Jupyter Notebook
Jupyter relies on kernels to execute the code contained within a notebook. For Python, we use the IPython kernel. With UV set up, you can install the IPython kernel using:
uv pip install ipykernel
This installation will allow Jupyter Notebooks to run code in VS Code seamlessly.
Step 4: Running and Executing Commands in Jupyter Notebooks
Now that you’ve installed the necessary extensions and tools, you are ready to start working with Jupyter Notebooks in VS Code.
- Open or Create a Notebook: You can create a new Jupyter Notebook from the Command Palette (
Ctrl+Shift+P
orCmd+Shift+P
on macOS) by typing ‘Jupyter: Create New Blank Notebook’. - Load Existing Notebooks: Simply drag and drop your existing
.ipynb
files into the VS Code editor or open them using the File Explorer. - Run Cells: Once your notebook is open, execute the code within by navigating to a cell and clicking the ‘Run’ button or using the shortcut (
Shift+Enter
). - Interactive Widgets and Outputs: The Jupyter extension supports interactive widgets and rich outputs, providing a dynamic and engaging environment for data exploration.
Conclusion
Integrating Jupyter Notebooks with VS Code revolutionizes the way you can manage and interact with your data science projects. With a professional-grade editor paired with the rich features of Jupyter, you can enhance productivity, streamline workflows, and consolidate various tasks within a single application.