# 用jupyter notebook来做数据分析

## Use jupyter notebook for CERN ROOT on Mac

Posted by Xuefeng Ding on April 18, 2021

As usual, I enjoyed setting up new tools. Jupyter-notebook is powerful as it visualizes data, saves worksapce data, and can execute any cell in any order you like.

In the past, I always try to make things work to its most extensive way, based on extensive understanding of the underlying logic. However, this is not the correct way to do analysis, nor the correct way to build software.

• First, we need to cooperate with others, and need to work without understanding the underlying bricks, so it is not good to spend time reading basics. “Read the fucking code” is only for specific projects, not for every project.
• Second, as I read from one book: let the platform help you, not fight against it. To reach that scenario, you need to understand how the authors of the platform designs it. Good paltform abandon a lot of possibilities. Freedom is traded off for guarentees and reliabilities, and in turn you got relief of burden of your minds.

So, following the same philosophy, I try to understand at least one configuration how ROOT works with JupyterNotebook and avoid making every combination works. It is too complicated and I need to focus on physics.

On Mac, I have conda and brew. Although I install conda hoping it can resolve the c++ environment, it is observed that conda does not solve any problem and can only used as virtualenv. So there is no hope for “one key installation for everything, and I need make them co-operate”

I use ROOT provided by brew. After grep, I found it is compiled with python 3.9. So I created a new conda env with python 3.9. Then it works.

the cpp magic is not usable at first, then I realize it is usable only after import ROOT.

To let “ROOT” appear in Jupyter-notbook, root root --notebook at least once, then

1
2
export JUPYTER_CONFIG_DIR=~/.rootnb
export JUPYTER_PATH=~/.rootnb


For more details please check Tueda’s nice tutorial