Running your own kernel

If you need to work with different language then Python, the Jupyter ecosystem provides you with a vast selection of other kernels. You can now run them in Deepnote!

Deepnote uses the environment variable DEFAULT_KERNEL_NAME that you set in the Dockerfile and uses it to create new notebooks with that kernel.

The best way to run a custom kernel is to find an existing image, for example on Dockerhub, and then set the environment variable DEFAULT_KERNEL_NAME.

To override the default kernel, modify the metadata in the .ipynb file.

An alternative way is to install the kernel into the default Deepnote image, see examples below.

R kernel

Pick your preferred version of R in the dropdown in the environment tab.

Installing R packages

In the default R environments

You can simply use the install.packages and library commands the way you normally would.

R packages often take a long time to install. We install them to your work folder by setting your environment variable R_LIBS_USER="~/work/.R/library", so they stay there during hardware restarts.

In your custom environment

If you're comfortable using your own Docker image, the preferred way would be to install the packages at build time, or pick from the large selection on Dockerhub.

Julia kernel

Use custom Dockerfile in the environment tab, and build an image with the following code:

FROM deepnote/python:3.7
RUN wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.2-linux-x86_64.tar.gz && \
tar -xvzf julia-1.6.2-linux-x86_64.tar.gz && \
mv julia-1.6.2 /usr/lib/ && \
ln -s /usr/lib/julia-1.6.2/bin/julia /usr/bin/julia && \
rm julia-1.6.2-linux-x86_64.tar.gz && \
julia -e "using Pkg;pkg\"add IJulia\""
ENV DEFAULT_KERNEL_NAME "julia-1.6"

Bash kernel

Use custom Dockerfile in the environment tab, and build an image with the following code:

FROM deepnote/python:3.7
RUN pip install notebook
RUN pip install bash_kernel && python -m bash_kernel.install
ENV DEFAULT_KERNEL_NAME "bash"

Scala 2.12.12 kernel (Almond 0.10.9)

Use custom Dockerfile in the environment tab, and build an image with the following code:

FROM deepnote/python:3.7
RUN wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
RUN apt update
RUN apt install -y software-properties-common
RUN add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
RUN apt update
RUN mkdir /usr/share/man/man1
RUN apt install -y adoptopenjdk-8-hotspot
RUN curl -Lo coursier https://git.io/coursier-cli
RUN chmod +x coursier
RUN ./coursier launch --fork almond:0.10.9 --scala 2.12.12 -- --install
RUN rm -f coursier
ENV DEFAULT_KERNEL_NAME "scala"

Or clone this project from Deepnote.

Racket kernel

Use custom Dockerfile in the environment tab, and build an image with the following code:

FROM deepnote/python:3.7
# The following snippet is licensed under MIT license
# SEE: https://github.com/jackfirth/racket-docker
RUN apt-get update && \
apt-get install -y libzmq5
RUN pip install notebook
ENV RACKET_INSTALLER_URL=http://mirror.racket-lang.org/installers/7.8/racket-7.8-x86_64-linux-natipkg.sh
ENV RACKET_VERSION=7.8
RUN wget --output-document=racket-install.sh -q ${RACKET_INSTALLER_URL} && \
echo "yes\n1\n" | sh racket-install.sh --create-dir --unix-style --dest /usr/ && \
rm racket-install.sh
ENV SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt"
ENV SSL_CERT_DIR="/etc/ssl/certs"
RUN raco setup
RUN raco pkg config --set catalogs \
"https://download.racket-lang.org/releases/${RACKET_VERSION}/catalog/" \
"https://pkg-build.racket-lang.org/server/built/catalog/" \
"https://pkgs.racket-lang.org" \
"https://planet-compats.racket-lang.org"
RUN raco pkg install --auto iracket
RUN raco iracket install
ENV DEFAULT_KERNEL_NAME "racket"

Thanks, @dkvasnickajr for sharing this!

You can clone this project from Deepnote.

Ruby

Use custom Dockerfile in the environment tab, and build an image with the following code:

FROM deepnote/python:3.7
RUN apt-get update -qq && apt-get install -y libtool libffi-dev make libzmq3-dev libczmq-dev
RUN apt-get install ruby-full -y
RUN gem install ffi-rzmq
RUN gem install iruby --pre
ENV DEFAULT_KERNEL_NAME=ruby

Then replace init.ipynb content with following:

!iruby register --force

After reseting the project state, you should be able to use Ruby in your notebooks.

Ruby On Rails

We have published a tutorial to help your run an existing Ruby on Rails project in Deepnote. One of the use cases is querying your data based on the existing ActiveRecord models, theirs scopes and relations.