Problem using ROOT with jupyter notebook

Hi,

I am facing problem using ROOT C++ kernel and JupyROOT for notebooks, I downloaded the binary release and followed installation instruction. I am able to run ROOT cmd line without problem but when I try to use run root --notebook and select the ROOT C++ kernel I get this :

Traceback (most recent call last): File "/home/vagrant/anaconda3/lib/python3.5/runpy.py", line 174, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/home/vagrant/anaconda3/lib/python3.5/runpy.py", line 109, in _get_module_details __import__(pkg_name) File "/home/vagrant/root/lib/JupyROOT/__init__.py", line 1, in <module> import JupyROOT.utils File "/home/vagrant/root/lib/JupyROOT/utils.py", line 17, in <module> import handlers ImportError: No module named 'handlers' [I 05:54:34.404 NotebookApp] KernelRestarter: restarting kernel (1/5) Traceback (most recent call last): File "/home/vagrant/anaconda3/lib/python3.5/runpy.py", line 174, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/home/vagrant/anaconda3/lib/python3.5/runpy.py", line 109, in _get_module_details __import__(pkg_name) File "/home/vagrant/root/lib/JupyROOT/__init__.py", line 1, in <module> import JupyROOT.utils File "/home/vagrant/root/lib/JupyROOT/utils.py", line 17, in <module> import handlers ImportError: No module named 'handlers' [I 05:54:37.427 NotebookApp] KernelRestarter: restarting kernel (2/5) Traceback (most recent call last): File "/home/vagrant/anaconda3/lib/python3.5/runpy.py", line 174, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/home/vagrant/anaconda3/lib/python3.5/runpy.py", line 109, in _get_module_details __import__(pkg_name) File "/home/vagrant/root/lib/JupyROOT/__init__.py", line 1, in <module> import JupyROOT.utils File "/home/vagrant/root/lib/JupyROOT/utils.py", line 17, in <module> import handlers ImportError: No module named 'handlers' [I 05:54:40.454 NotebookApp] KernelRestarter: restarting kernel (3/5) Traceback (most recent call last): File "/home/vagrant/anaconda3/lib/python3.5/runpy.py", line 174, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/home/vagrant/anaconda3/lib/python3.5/runpy.py", line 109, in _get_module_details __import__(pkg_name) File "/home/vagrant/root/lib/JupyROOT/__init__.py", line 1, in <module> import JupyROOT.utils File "/home/vagrant/root/lib/JupyROOT/utils.py", line 17, in <module> import handlers ImportError: No module named 'handlers' [W 05:54:41.580 NotebookApp] Timeout waiting for kernel_info reply from b7a21fb3-b25a-4ae3-a44e-a98db37313a9 [I 05:54:43.474 NotebookApp] KernelRestarter: restarting kernel (4/5) WARNING:root:kernel b7a21fb3-b25a-4ae3-a44e-a98db37313a9 restarted Traceback (most recent call last): File "/home/vagrant/anaconda3/lib/python3.5/runpy.py", line 174, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/home/vagrant/anaconda3/lib/python3.5/runpy.py", line 109, in _get_module_details __import__(pkg_name) File "/home/vagrant/root/lib/JupyROOT/__init__.py", line 1, in <module> import JupyROOT.utils File "/home/vagrant/root/lib/JupyROOT/utils.py", line 17, in <module> import handlers ImportError: No module named 'handlers' [W 05:54:46.491 NotebookApp] KernelRestarter: restart failed [W 05:54:46.492 NotebookApp] Kernel b7a21fb3-b25a-4ae3-a44e-a98db37313a9 died, removing from map. ERROR:root:kernel b7a21fb3-b25a-4ae3-a44e-a98db37313a9 restarted failed! [W 05:54:46.539 NotebookApp] Kernel deleted before session [W 05:54:46.540 NotebookApp] 410 DELETE /api/sessions/dd83415a-07b9-43f1-9e28-0ce639da22bc (10.0.2.2) 2.48ms referer=http://localhost:8007/notebooks/Untitled3.ipynb?kernel_name=root

the kernel basically can’t be started due to some missing module.
ImportError: No module named ‘handlers’

I have installed anaconda for python 3.4(is it a problem that the binary is configured for 2.7).

here is the config of root:

I also copied the kernels in ~/.local/share/… to use with the notebook and not requiring root intervention but same problem. I didn’t use jupyter kernel spec because it’s already present.

between: for now, I am interested in the kernels provided by root, so is there a possibility to use only cling and mix C++ with python or it’s only possible for through root?

1 Like

Hi,

the problem is that the binaries are prepared for python 2.7 and you are using python3.5.
Cling also provides a kernel: github.com/root-mirror/cling/tr … ls/Jupyter

Cheers,
Danilo

thx for the answer!
so do I have to build ROOT from source or is there a pre-build binary for 3.5?

yes I know about cling kernel, but what I want to know is is there a possibility to use magics with that kernel?

Hi,

unfortunately there are not python3 binaries yet. What you may do is to provide python2 on your system or, indeed, as you propose, build from sources. The support for python3 in Jupyroot has been added ~1 week ago in the ROOT master though, so this would require you to jump to the bleeding edge.

What magics are you referring to in particular :slight_smile:?

Cheers,
Danilo

1 Like

thx, so I guess I will(I.A.) download anaconda for python 2.7.

jupyter cells magics cmd for example %%cpp, %%lsmagics

Hi,

the magics to build and load cell content as shared objects are specific to root only. %lsmagic on the other hand is a property of kernels and is available everywhere.

Cheers,
D

sorry for the late reply, but %lsmagics doesn’t work in cling kernel

The right name for the magic is %lsmagic: did you mean that one?

yes I tested %lsmagics with cling kernel it didn’t work, and I switched in the same document to ipy kernel and it did work. I think that they forward every think to cling interpreter and they suppose every thing you write is meant for cling.

Hi,

I think the right syntax is %lsmagic and not %lsmagics: did you try that? If you are interested the ROOT kernel, which is based on metakernel, will have this and other goodies embedded.

Cheers,
D

hi,
sorry typo in reply, but I wrote %lsmagic correctly in jupy ntb.
I have got a problem with ROOT with the python version if I remember correctly. plus I don’t need the ROOT framework at least for know I just need utilities provided whicha re basically %cpp magics and C++ kernel.

Hello @Danilo, @cppchedy,

I faced the same

ImportError: No module named 'handlers'

problem on our jupyterhub. I fixed it by specifying python2 explicitly in the kernel spec, i.e. changing the first argv element from python to /usr/bin/python2.

Cheer,
Hans

root@alice-head:~# cat /usr/local/share/jupyter/kernels/root/kernel.json
{
 "language": "c++",
 "display_name": "ROOT C++",
 "argv": [
  "/usr/bin/python2",
  "-m",
  "JupyROOT.kernel.rootkernel",
  "-f",
  "{connection_file}"
 ]
}
root@alice-head:~# 

Hi,

this is correct. You can use the pythonX kernel if you built ROOT against pythonX (with X equal to 2 or 3).

Cheers,
D