Add Kernels for Multiple Languages in Jupyter Notebook
Jupyter Notebook is a very convenient tool because it allows you to combine code, output, and explanations written in Markdown all in one place.
By default, Jupyter Notebooks support Python, but by adding Jupyter kernels, you can also use other programming languages.
This article covers the following topics.
- Jupyter kernels
- List of Jupyter kernels
- Installation
- Example of adding Bash
Jupyter kernels
List of Jupyter kernels
You can find a list of currently available Jupyter kernels on this page:
Numerous kernels are available for various programming languages, including Ruby, C#, Go, and more.
Each kernel is community-created, and some languages may have multiple kernels. The table on the linked page provides repository links in the leftmost column. You can assess these repositories by considering the number of stars and the date of the most recent update.
Installation
The installation method varies depending on the kernel. In many cases, repositories provide installation instructions for different environments like Linux, macOS, and Windows.
Some kernels may require complex environment setup. Not all of them are easy to handle.
Example of adding Bash
As a specific example, let's add Bash.
Follow the README instructions to install the Bash kernel, which is relatively simple.
$ pip install bash_kernel
$ python -m bash_kernel.install
Launch Jupyter Notebook as usual with the jupyter notebook
command.
$ jupyter notebook
When you click the New
button (located at the top right) to create a new notebook, you'll see Bash
added to the list along with Python3
. Clicking Bash
will create a notebook that runs Bash. The file extension remains .ipynb
.
Usage of the notebook is the same as with Python.
Type shell commands in input cells and execute them to display the results.
Here's an example of an actual notebook:
Using Jupyter Notebook with the Bash kernel allows you to keep command outputs as logs. There's no need to copy and paste terminal displays, making it easier to reproduce results later.