I am setting up a brand new Mac M2. OS is Sonoma (14.2)
I installed homebrew.
Next, I installed root with “brew install root”.
Vanilla root works.
This also installs Python 3.11 etc. as a dependency.
Next, I install jupyter with pip3.
Neither jupyter-notebok nor jupyter-lab worked.
For jupyter-lab the problem is the same as this StackOverflow post
Following the hints in that post, I solved it by setting
c.LabApp.app_dir = ‘/opt/homebrew/share/jupyter/lab’
in the jupyter config file
/opt/homebrew/etc/notebook/jupyter_lab_config.py
For good measure, I also did
export JUPYTER_PATH=/opt/homebrew/share/jupyter
export JUPYTER_CONFIG_PATH=/opt/homebrew/etc/jupyter
but I am not sure that it was necessary.
Now both jupyter-notebook and jupyter-lab work.
However, when I do
root --notebook
I get a lot of errors (1) and the opened webpage is blank (only has the jupyter logo). I think I was getting the same identical behavior when trying jupyter-notebook as opposed to jupyter-lab before the fixes above.
So it smells like the config file is not picked up in this case (?).
Also: the ROOT kernel does not show up in Jupyter-lab.
Any ideas?
Thanks
Claudio
(1) The full output is here
PS: These are the jupyter versions that are installed
Thanks for reaching out to the forum! Let me try to bring some clarity to the situation:
I don’t think root --notebook has any notion of JupyterLab per se, it only opens a Jupyter notebook instance. If import ROOT works in the normal Jupyter notebook (i.e. via jupyter-notebook) I am not sure that this can translate 1:1 to JupyterLab
Ideally, one would use ROOT inside the environment where either Jupyter or JupyterLab are. From your description above, it looks like you are creating two different environments. The one with homebrew and the one with pip. This is usually recipe for confusion and unexpected bugs, so I would avoid it in general (i.e. irrespective of ROOT).
It is crucial that the Python executable that you use to import ROOT in any circumstance, i.e. at a Python prompt, executing python myscript.py, opening a Jupyter notebook or a JupyterLab instance etc. is the very same Python executable used to create the ROOT installation. In your situation above, whatever Python was used to create the homebrew package (and again here comes the problem that you are then installing Jupyter separately).
I am pretty sure it is not an issue with different environment – pip and python and root are installed by brew, everything is “together”.
It is also not an issue with jupyter-lab vs. jupyter-notebook. Essentially jupyter-lab is a wrapper around the notebook (and much more).
Checking out the error messages and doing some further googling I solved the problem at the 90% level.
Here is what I did, for posterity and since it may help someone else eventually.
There were several errors about not found jsons in this directories:
/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/share/jupyter/lab/schemas/@jupyterlab/XXX-extension
where XXX=applications, apputils, notebook, shortcut, … etc etc
I found that in the installation straight out of brew
/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/share/
only has a doc subdirectory
Now
root --notebook
works!
(Opens a vanilla notebook, no through the lab).
Most jsons are now found, but not all.
The missing jsons are:
blah_blah_blah/@jupyter-notebook/application-extension/shell.json
blah_blah_blah/@jupyter-notebook/notebook-extension/scroll-output.json
blah_blah_blah/@jupyter-notebook/tree-extension/widget.json
These errors do not seem to be fatal, so for now I ignore them.
I said that it works at the 90% level because when I do
jupyter-notebook
or
jupyter-lab
The ROOT kernel is not available. It is only available with
root --notebook
Not a big deal…
At some point I may try to figure out how to “register” the ROOT kernel with jupyter…do you have suggestions?
This is the thing, I never use root --notebook myself. I always open a Jupyter notebook and I can import ROOT normally as any other Python package. So I am not sure why in your case this doesn’t work. To be further debugged.
I can do
import ROOT
in a jupyter python kernel (lab or notebook), and it works.
What I am not able to do is to select the ROOT C++ kernel when starting jupyter (lab or notebook). I can only select it when the notebook is started via
rooot --notebook
In contrast, on my old mac that I had setup some time ago the ROOT C++ kernel is available when starting jupyter (lab or notebook) as well as with “root --notebook”.
See screenshot linked below (from my old intel mac…notebook started with “jupyter-notebook” command.)
To be fair, I seem to remember that setting this up on the old mac was not entirely smooth…but I do not remember what I did.
Thank you for the further clarification, now I see what the problem is. We need to investigate what happened that made the C++ kernel disappear, if it’s a problem only for the most recent Mac or if it is also a problem in newer ROOT versions irrespective of the platform.
Have a nice holiday break!
Cheers,
Vincenzo