LoginSignup
0
1

More than 3 years have passed since last update.

Installing ROOT and Jupyter for ROOTbook via Homebrew/Linuxbrew

Last updated at Posted at 2020-03-23

Homebrew/Linuxbrew can install ROOT and Jupyter. But Homebrew uses venv to install Jupyter, which makes the use of ROOTbook a bit complicated.

Jupyter Notebook + ROOT

First, install ROOT and Jupyter. Additionally, the metakernel package is required for C++ notebooks.

Terminal
brew install jupyterlab root
pip3 install metakernel --no-dependencies  # many of the dependencies are in venv
pip3 install ipyparallel portalocker --no-dependencies  # not in venv

In practice, you may also want to install matplotlib etc. via pip3.

Then, make your customised root command:

.bashrc
root() {
  (
    brew=$(command -v brew)
    . $(brew --prefix root)/bin/thisroot.sh  # this changes $PATH
    export PATH=$($brew --prefix jupyterlab)/libexec/bin/:$PATH
    command root "$@"
  )
}

Run it.

Terminal
root --notebook --no-browser

Check if simple examples work, e.g.,

Jupyter (Python 3)
import ROOT
c = ROOT.TCanvas()
f = ROOT.TF1("f", "sin(x)/x", 0.0, 10.0);
f.Draw();
c.Draw();
Jupyter (ROOT C++)

TCanvas c;
TF1 f("f1", "sin(x)/x", 0.0, 10.0);
f.Draw();
c.Draw();

JupyterLab + ROOT

The command root --notebook in the above section creates a customised Jupyter configurations in ~/.rootnb. One can make use of it for JupyterLab:

.bashrc
rootlab() {
  JUPYTER_CONFIG_DIR=~/.rootnb JUPYTER_PATH=~/.rootnb jupyter lab "$@"
}
Terminal
rootlab --no-browser

Tested environment

CentOS 7 (x86_64)
root        6.20.02
jupyterlab  2.0.1
metakernel  0.24.3
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1