Running CPP and JS Kernel in Deepnote Jupyter Notebook

The Mythical Engineer

If you need to work with a language other than Python, the Jupyter ecosystem offers a wide range of other kernels. Deepnote supports a lot of them!

Deepnote Official documentation has instructions on setting up R, Julia, Bash, Scala and Ruby.

I was recently attempting to set up a C++ and Javascript kernels and finally figured out how to make it work. You can read more about Interactive CPP with Cling.

Dockerfile for C++ Kernel

FROM deepnote/python:3.9
RUN apt-get update && \
    apt-get install -y g++ libtinfo5
RUN pip install jupyter-console
RUN wget && \
    tar -xf cling_2020-11-05_ROOT-ubuntu18.04.tar.bz2 && \
    cd cling_2020-11-05_ROOT-ubuntu18.04/share/cling/Jupyter/kernel && \
    pip install -e . && \
    jupyter-kernelspec install --user cling-cpp17
ENV PATH="cling_2020-11-05_ROOT-ubuntu18.04/bin:$PATH"
RUN jupyter console --kernel cling-cpp17

Configure Dockerfile

After the completion of the build, you can execute C++ in the deepnote notebook.

CPP Example

Some things that don’t work in this version, but maybe supported in upcoming versions of the kernel

  1. Function redefinitions are not allowed. Issue Link

  2. You cannot define more than one function in a block. Issue Link

You can also try to build the latest version and try out these features.

IJavascript is a Javascript kernel for the Jupyter notebook. I used the commands provided on the official repository of the project to create this Dockerfile.

Dockerfile for Javascript Kernel

FROM deepnote/python:3.9
RUN pip install jupyter-console
RUN apt-get update && apt-get install -y g++ libzmq3-dev nodejs npm
RUN npm install -g --unsafe-perm ijavascript
RUN ijsinstall --install=global
RUN jupyter console --kernel javascript

Follow the same process as above for configuring the environment and you’re ready to run Javascript in Deepnote Notebook.

JS Example

#development  #jupyter  #docker  #deepnote 

Suggested Reading

  • * How Postgres Triggers Can Simplify Your Backend Development

    * Running Rust Kernel in Deepnote

    * List of most used Key-Value stores and databases

    * Docker Pull Too Many Requests

    * Change the default editor in Linux

  • Share this: