Skip to content

Jupyter Kernels and the Jupyter Extension

Aaron Munger edited this page Jul 18, 2022 · 8 revisions

Jupyter Kernels

When the Visual Studio Code Jupyter Extension is executing cells it's using Jupyter kernels to execute the code and get back output to display in the notebook document. Users can install kernelspec files for all different languages on their system. By installing them into the same locations as Jupyter they will get picked up by the Jupyter extension and should show up as options in the notebook kernel picker. These kernel will be shown in the kernel picker under the group label "Jupyter Kernel."

Jupyter Kernels section of the kernel picker.

Python Extension and IPyKernel

Without the Python Extension installed the Jupyter Extension can pick up kernels installed into Jupyter registered locations and run them. But with the Python Extension installed new options are opened up for Python notebooks. Instead of being restricted to just registered Jupyter kernels any Python environment, meaning a Python interpreter and an associated location for Python packages, installed on the system can be used as a kernel to execute Python code in. The default kernel for Python is provided by the IPyKernel package. If you select an environment on the system that does not have IPyKernel installed and attempt to run the notebook you will be prompted to install IPyKernel. If it's installed, that environment can be used as a valid kernel for Jupyter notebooks in Visual Studio Code.

image

The Python Extension can detect many different types of Python environments on a system and has an excellent guide to setting them up. In the kernel picker those interpreters will all be grouped up into different categories based on the interpreter type.

PythonKernels

Kernel Selection

When you pick a kernel in the kernel picker, that kernel will then be associated with that file and automatically selected the next time that you open it. If nothing has been selected, the Jupyter Extension will take a look at the notebook metadata and attempt to select the best kernel for the file. That kernel will be label as the "suggested" kernel. For Python, if no environments look like an exact match the selected active environment of the Python Extension in the given workspace will be used.

image

Note that when you have a kernel selected that only supports specific languages the code cells in the notebook document will be restricted to only the types supported by the current kernel.

image

Other Extensions providing kernels

There are other notebook extensions in the marketplace such as the Julia or the .NET Interactive that can also provide kernels. These kernels will show up in the kernel picker alongside those provided by the Jupyter Extension.

image
Clone this wiki locally