Open notebooks with no kernel & without "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