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