Open notebooks with no kernel & without "Select Kernel" popup

Hi!

Is there a way to open an notebook in JupyterLab (v4.1.6) without starting any kernels and without having the “Select Kernel” popup appear each time I open a notebook without a kernel specified under its “kernelspecs”?

I have tried setting the “kernelspecs” of notebooks to the following, but JupyterLab keeps asking me to select a kernel:

{
  "cells": [],
  "metadata": {
    "kernelspec": {
      "display_name": "",
      "language": "",
      "name": null
    }
  }
}

I have also seen this post: How to open a notebook without starting the kernel
But I don’t want to use “nbviewer”. JupyterLab offers the possibility to open a notebook without running a kernel, which is good enough. I just want it to be automatic depending on the notebook’s metadata, if possible. Either from the notebook’s metadata, or from a Notebook/Server/JupyterLab configuration.

Or, maybe, is there a way to disable the “Select Kernel” popup?

It is possible to disable automatic kernel start when opening a notebook through a JupyterLab configuration. This configuration in turns disables the “Select Kernel” popup when opening an notebook with an empty “kernelspec” field.

I found out about this configuration in the following GitHub issue: Open a notebook with no kernel or an existing kernel · Issue #12019 · jupyterlab/jupyterlab · GitHub

The configuration can be found in the following JupyterLab API docs: Application — JupyterLab Server 2.26.0 documentation

The solution is to add the following line inside JupyterLab’s configuration file (e.g., .jupyter/jupyter_lab_config.py):

# Whether a notebook should start a kernel automatically
c.LabServerApp.notebook_starts_kernel = False

In addition, I have removed the default kernel.

First by using the following command (e.g., in the postBuild file):

# Remove kernels
jupyter kernelspec remove -y python3

Then by using the Notebook/Server configuration below (e.g., .jupyter/jupyter_notebook_config.py or .jupyter/jupyter_server_config.py):

# If there is no Python kernelspec registered and the IPython
# kernel is available, ensure it is added to the spec list
c.KernelSpecManager.ensure_native_kernel = False

source: jupyter notebook - Jupyterlab: How to remove/hide default "Python 3" Kernel? - Stack Overflow

docs: Config file and command line options — Jupyter Server documentation

1 Like