Having multiple kernels available for Jupyter service, we may need to manage them at some point, e.g., rename kernel names and remove kernels. First, to show all available kernels, run the following command,
jupyter kernelspec list
we will then see output like this,
Available kernels:
python3 /opt/jupyterhub/lib64/python3.6/site-packages/ipykernel/resources
diffpy /usr/local/share/jupyter/kernels/diffpy
py37 /usr/local/share/jupyter/kernels/py37
python /usr/local/share/jupyter/kernels/python
This is the full list of all available kernels on our machine and the directory specifies where the configuration file for each kernel is located. To change kernel name, we then need to go into the corresponding directory for a specific kernel and open the ‘kernel.json’ file to change the ‘display_name’ entry to whatever we want.
To remove a kernel, we want to use the following command,
jupyter kernelspec remove KERNEL_NAME
For example, if we want to remove the ‘diffpy’ kernel above, we want to execute,
jupyter kernelspec remove diffpy
Among all the available kernels, there is a special one - the ‘base’ JupyterHub kernel from kernelspec. The ‘python3’ kernel shown above is just the ‘base’ JupyterHub kernel. If we try to remove this kernel, it will complain that the kernel cannot be found. Here in Ref. [1] is given detailed description and solution to this issue. To remove this base kernel, as posted in Ref. [1], there are two main things to do, 1) rename one of the other kernels to the base kernel name [2] and 2) disable native kernel by changing Jupyter configuration file [3]. Concerning the second part, we may need to create Jupyter configuration file first if it is not already existing, as instructed in Ref. [4].
References
[1] https://github.com/jupyterhub/jupyterhub/issues/2759
[2] https://github.com/jupyterhub/jupyterhub/issues/2759#issuecomment-538139098
[3] https://github.com/jupyterhub/jupyterhub/issues/2759#issuecomment-770025308