-
Notifications
You must be signed in to change notification settings - Fork 292
Jupyter Kernels and the Jupyter Extension
The Jupyter Kernels category lists all Jupyter kernels that VS Code detects in the context of the compute system it’s operating in (your desktop, Codespaces, remote server, etc.). Each Jupyter kernel has a Jupyter kernel specification (or Jupyter kernelspec), which contains a JSON file (kernel.json
) with details about the kernel—name, description, and CLI information required to launch a process as a kernel.
When the Visual Studio Code Jupyter extension is executing cells, it's using Jupyter kernels to execute the code and retrieve output to display in the notebook document. Users can install kernelspec files for 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..."
When the Python extension is installed, 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. Without the Python extension installed, the Jupyter extension can only find kernels installed into Jupyter-registered locations. 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.
Note: You do not need to install jupyter into the Python environment you want to use. Only IPython and IPyKernel are required to launch a Python process as a kernel and execute code against your notebook, e.g.,
pip install ipython ipykernel
. Visit our wiki to learn more.
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.
The Existing Jupyter Server category lists remote Jupyter servers previously connected. You can also use this option to connect to an existing Jupyter server running remotely or locally. Grab the URL for your Jupyter server, e.g., http://<ip-address>:<port>/?token=<token>
and paste it in the Enter the URL of the running Jupyter server
option to connect to the remote server and execute code against your notebook using that server.
Note: When you’re starting the Jupyter server, ensure to: (1) allow all origins (e.g.,
--NotebookApp.allow_origin = '*'
) to allow your servers to be accessed externally, and (2) set the notebook to listen to listen on all IPs (e.g.,--NotebookApp.ip = '0.0.0.0'
). Once connected, all active Jupyter sessions will appear on this list. You can create new session from the server’s kernelspec by selecting theNotebook: Select Notebook Kernel
command ->Select Another Kernel…
->Local Kernel Specs…
-> your server. Member
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.
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.
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.
- Contribution
- Source Code Organization
- Coding Standards
- Profiling
- Coding Guidelines
- Component Governance
- Writing tests
- Kernels
- Intellisense
- Debugging
- IPyWidgets
- Extensibility
- Module Dependencies
- Errors thrown
- Jupyter API
- Variable fetching
- Import / Export
- React Webviews: Variable Viewer, Data Viewer, and Plot Viewer
- FAQ
- Kernel Crashes
- Jupyter issues in the Python Interactive Window or Notebook Editor
- Finding the code that is causing high CPU load in production
- How to install extensions from VSIX when using Remote VS Code
- How to connect to a jupyter server for running code in vscode.dev
- Jupyter Kernels and the Jupyter Extension