Jupyter notebook with multiple languages

Nicola Landro
3 min readJun 15, 2019

--

Jupyter can create different language notebook

Jupyter is a good instrument to create sheet with code and explanation inside. It is very usefull for tutorial or also for slide with RISE plugin.

But from default it use only python language and you can easily add different python virtual environment with different libraries version and different pyton version.

Use a notebook is interesting also with other language, or with multiple languages in one notebook, so I decide to create a docker container with some language inside:

Basic usage with docker

To use it with docker is very simple, you can exec:

$ docker run -v /path/to/your/notebook/folder:/server/notebook -p 8888:8888 nicolalandro/multilanguage-jupyter:1.0

And then go to http://localhost:8888/tree/notebook to see jupyter.

What language was inside?

Obviously the python3 is present, because I use it to run jupyter at first.

The first language that I add is Coq. It is a formal proof assistant that help you to do formal proof often used to proof some properties of your code. It will be easy with coq-jupyter.

I add SoS kernel that provide the possibility to use multiple language inside one notebook, for example I can write a python function and then I can proof some properties of it with coq.

A functional programming language very famous is Scala that use the JVM so I install also Java. For java into jupyter I use IJava, instead for scala I use almond.

My working language now, as a fan of TDD, is Ruby, and for web front-end is necessary also Javascript, so I add both. Ruby using IRuby and javascript using Ijavascript.

This is only a small list of languages that it is possible to add to jupyter, a more big list of the jupyter kernels can be found here on the github jupyter project wiki.

Docker container

The project folder has this shape:

./multilanguage-jupyter
--- ijava-1.3.0/ # download form ijava relise
--- almond # download from almod guide
--- requirements.txt
--- Dockerfil

The first two file is download by theirs projects.

The requirements.txt

jupyter
coq-jupyter
rise
jupyter_nbextensions_configurator
jupyter_contrib_nbextensions
sos
sos-notebook

The Dockerfile

FROM ubuntu# Install coq e python
RUN apt-get update && apt-get install -y coq coqide python3-dev python3
RUN apt-get update && apt-get install -y python3-pip
# Install java
RUN apt-get update && apt-get install -y openjdk-11-jdk
# Install scala
RUN apt-get update && apt-get install -y wget
RUN wget https://downloads.lightbend.com/scala/2.11.0/scala-2.11.0.tgz && tar -xvzf scala-2.11.0.tgz && rm scala-2.11.0.tgz
ENV SCALA_HOME=/scala-2.11.0
ENV export PATH=$PATH:$SCALA_HOME/bin:$PATH
# Install Ruby
RUN apt-get update && apt-get install -y libtool libffi-dev ruby ruby-dev make
RUN apt-get update && apt-get install -y libzmq3-dev libczmq-dev
# Install Nodejs
RUN apt-get update && apt-get install -y nodejs npm
# Install jupyter and python dependency
WORKDIR /server
ADD requirements.txt /server/requirements.txt
RUN pip3 install -r requirements.txt
# Configure jupyter plugin for install extension
RUN jupyter contrib nbextension install --user
RUN jupyter nbextensions_configurator enable --user
# Configure coq (proof assistant)
RUN python3 -m coq_jupyter.install
# Configure sos (for multi lenguage into a notebook)
RUN python3 -m sos_notebook.install
# Configure Java
ADD ijava-1.3.0 ./ijava-1.3.0
RUN ls
RUN cd ijava-1.3.0 && python3 install.py --sys-prefix
# Configure Scala
ADD almond .
RUN ./almond --install
# Configure Ruby
RUN gem install cztop
RUN gem install iruby --pre
RUN iruby register --force
# Configure javascript
RUN npm install -g ijavascript
RUN ijsinstall
CMD jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root --NotebookApp.token=''

So this is my multi language jupyter project. I hope that is will be usefull for someone.

--

--

Nicola Landro
Nicola Landro

Written by Nicola Landro

Linux user and Open Source fun. Deep learning PhD. , Full stack web developer, Mobile developer, cloud engineer and Musitian.

No responses yet