Installing and configuring packages

In Nextjournal’s runtimes you can install any package or library, and configure them in whatever way works best for you. For most programming languages, the preferred way of installing packages will be to use a Bash script, but some, like R, might use their own runtime for it. Here, we first recap quickly on how to use Bash cells for installing packages (that you can skip if you've already read this guide), and then provide a collection of examples of package installations in different languages.

Using Bash for package installation

Currently, the language used for code cells and their corresponding runtimes are coupled, meaning a Python runtime will only use Python cells, a R runtime only R cells, and so on. Bash is an exception here. Since Bash is often used to install packages, Nextjournal allows assigning Bash cells to other language runtimes.

Nextjournal tries to facilitate the process by guessing your intent when you add a Bash cell:

If no other runtimes exist, Nextjournal will add a standalone Bash runtime.

If other, non-Bash runtimes exist, Nextjournal will take the most recent cell’s runtime and assign the Bash cell to that runtime, assuming that you want to install packages for it. This will be indicated by Bash in [Language] in the bottom right corner of a code cell:

pip install climt
Bash in Python

Manually assigning cells to runtimes

You can always manually assign your Bash cells to different runtimes: simply open the Bash cell’s options menu and select Change runtime…, then select the runtime you want it to assign to:

Installing Packages

Each Nextjournal runtime comes with an environment based on Ubuntu 18.04 LTS. This means that you can install packages from files via dpkg, or fetch them from repositories with apt-get. Nextjournal’s default environments don’t have package lists stored so an apt-get update might be required first:

apt-get update
apt-get install fortune cowsay
/usr/games/fortune | /usr/games/cowsay

Prevent having to re-install packages

A Nextjournal runtime’s file system state is transient by default. This means that whenever the runtime shuts down or is reset (either by your action or because it automatically shut down after 20 minutes of idle time), all installed packages are lost and have to be re-installed again. To prevent this, save your environment after installing packages to persist their file system state and all installed packages. You might want to read How to reuse your environments for a short tutorial. Once you saved the runtime’s environment, you can assign it to your runtime so your code cells have the packages available to them.

What follows here is a collection of examples on how to install packages for individual programming languages.

Installing Python Packages

Nextjournal's default Python 2 and 3 environments have a number of basic data and plotting packages installed, including numpy, matplotlib, and plotly:

pip freeze
Bash in Python

When additional Python packages are required, you can install them in multiple ways. The easiest is to use conda, which will attempt to install all packages and dependencies in a consistent manner, including system packages and libraries. The Anaconda Cloud has a searchable database of packages and channels — by default conda will select only from the anaconda channel.

conda install descartes pysal
Bash in Python

Additional channels can be added with the -c flag.

conda install -c conda-forge cartopy
Bash in Python

For packages and versions unavailable via conda, or for installing packages distributed as wheel files, pip is available. For any packages that require compilation, gcc is available along with the most common build tools.

pip install quilt mapclassify
Bash in Python

You can also use pip to install development versions from git repos.

pip install git+
Bash in Python

Finally, if a package has a, you can download and install with that.

git clone
cd geoplot
git checkout 328cc9d5f8c02470c6257f2bf2fb2f3c5304530f
python install
Bash in Python

Installing Clojure Packages

The default Clojure environment provides Clojure v1.10.0. Other versions, and any required libraries or packages, can be installed using a deps.edn file. In order to ensure loading when the runtime boots, this file must be created by inserting a Code Listing. Simply click the + button between nodes and select Code Listing, then set its language (in the bottom right corner) to Extensible Data Notation, and assign it deps.edn as its name using its options menu (•••) in the upper left corner. The following example will install the clj-xchart library:

{ :deps { com.hypirion/clj-xchart {:mvn/version "0.2.0"} 
          org.clojure/clojure { :mvn/version "1.10.0-beta8" }}}
Extensible Data Notation

Your deps.edn can then be mounted into the Clojure runtime’s file system to be read at boot time using the runtime’s settings panel:

Booting will take an extended length of time because of the installation happening through deps.edn. It is advisable to save the environment once all of the packages are installed so you not have to run through this process whenever you reset the runtime.

System packages that are required for clj-xchart can be installed via a Bash cell:

apt-get update
apt-get install --no-install-recommends \
  fontconfig libxext6 libxrender1 libxtst6 libxi6
Bash in Clojure

Once everything has been installed, we can require clj-xchart:

(require '[com.hypirion.clj-xchart :as c])

Installing Julia Packages

The Julia default environment includes a wide variety of file-handling and data processing packages, as well as the Plots and Makie graphical frameworks.

inst = Pkg.installed()
foreach(key-> println("$key v$(inst[key])"), keys(inst))

Installation of additional packages is done via the the standard Julia Pkg interface: update will upgrade all packages with newer versions available, and add will install new packages. Running precompile before saving an environment will speed up package loading in the future.

pkg"add LightGraphs GraphPlot"

One can also use the `]` pkg mode to install packages:

]up; add UnicodeFun

Installing R Packages

The R environment includes the tidyverse, and the plotly and ggplot2 graphical packages.

inst = installed.packages()[,c("Package","Version")]

As always, a Bash cell can install additional dependencies:

apt-get update
apt-get install libudunits2-dev
apt-get clean
Bash in R

Installation of additional R packages is done via the the standard R function install.packages(), or the devtools function install_github(). Build tools, including gcc, are included for package compilation.


Once the packages have been installed, we can require them:


Configuring Packages

Environment Variables

Besides using a Bash script for configuration, or a deps.edn code listing mounted into Clojure runtimes (see section above), any runtime also has full control over its environment variables. To create or override env variables, open a runtime’s settings panel, and expand the Environment Variables & Secrets section:

⚠️: the runtime must be booted up in order for its inherited environment variables to be shown.

Runtimes (5)