Jupyter Kernels: How to Add, Change, Remove

Last updated:
Table of Contents

Add Virtualenv as Python Kernel

Replace your-venv with your virtualenv name

  • Activate the virtualenv

    $ source your-venv/bin/activate
    
  • Install jupyter in the virtualenv

    (your-venv)$ pip install jupyter
    
  • Add the virtualenv as a jupyter kernel

    (your-venv)$ ipython kernel install --name "local-venv" --user
    
  • You can now select the created kernel your-env when you start Jupyter

Add Apache Spark Kernel

You need a local Apache Spark installation: download Spark

Use a Jupyter plugin called Apache Toree.

Install the plugin into a Python installation that already has jupyter:

$ pip install jupyter 
$ pip install --upgrade toree
$ jupyter toree install --spark_home=/home/felipe/Downloads/spark-2.4.3-bin-hadoop2.7
$ jupyter notebook

adding-spark-kernel-jupyter Start jupyter with the toree plugin
and you'll be able to link jupyter to
an existing local spark installation

Add Scala Kernel

TODO: see https://github.com/almond-sh/almond

List kernels

Use jupyter kernelspec list

$ jupyter kernelspec list
Available kernels:
  global-tf-python-3    /home/felipe/.local/share/jupyter/kernels/global-tf-python-3
  local_venv2           /home/felipe/.local/share/jupyter/kernels/local_venv2
  python2               /home/felipe/.local/share/jupyter/kernels/python2
  python36              /home/felipe/.local/share/jupyter/kernels/python36
  scala                 /home/felipe/.local/share/jupyter/kernels/scala

Remove kernel

Use jupyter kernelspec remove <kernel-name>

$ jupyter kernelspec remove old_kernel
Kernel specs to remove:
  old_kernel            /home/felipe/.local/share/jupyter/kernels/old_kernel
Remove 1 kernel specs [y/N]: y
[RemoveKernelSpec] Removed /home/felipe/.local/share/jupyter/kernels/old_kernel

Change Kernel name

  • 1) Use $ jupyter kernelspec list to see the folder the kernel is located in

  • 2) In that folder, open up file kernel.json and edit option "display_name"

Dialogue & Discussion