Jupyter Notebook with ROOT C++ Kernel

Hi,

I’m fairly new to the whole Jupyter notebook and have just tried to give the ROOT kernel a shot, it failed immediately. Any hints on what I may have done wrong?

Dead kernel

The kernel has died, and the automatic restart has failed. It is possible the kernel cannot be restarted. If you are not able to restart the kernel, you will still be able to save the notebook, but running code will no longer work until the notebook is reopened.
[W 16:20:07.662 NotebookApp] Session not found: session_id='22c741fd-2fb3-4442-91ec-8beb07b6254a'
[W 16:20:07.662 NotebookApp] 404 DELETE /api/sessions/22c741fd-2fb3-4442-91ec-8beb07b6254a (::1) 0.98ms referer=http://localhost:8888/notebooks/Documents/Notebooks/Untitled.ipynb?kernel_name=root
[I 16:20:07.679 NotebookApp] Kernel started: cc450642-22d6-42ee-a051-d423d774b5ae
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/opt/root/root-6.08.06/lib/JupyROOT/__init__.py", line 1, in <module>
    import JupyROOT.utils
  File "/opt/root/root-6.08.06/lib/JupyROOT/utils.py", line 17, in <module>
    import handlers
ModuleNotFoundError: No module named 'handlers'
[I 16:20:10.679 NotebookApp] KernelRestarter: restarting kernel (1/5)
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/opt/root/root-6.08.06/lib/JupyROOT/__init__.py", line 1, in <module>
    import JupyROOT.utils
  File "/opt/root/root-6.08.06/lib/JupyROOT/utils.py", line 17, in <module>
    import handlers
ModuleNotFoundError: No module named 'handlers'
[I 16:20:13.687 NotebookApp] KernelRestarter: restarting kernel (2/5)
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/opt/root/root-6.08.06/lib/JupyROOT/__init__.py", line 1, in <module>
    import JupyROOT.utils
  File "/opt/root/root-6.08.06/lib/JupyROOT/utils.py", line 17, in <module>
    import handlers
ModuleNotFoundError: No module named 'handlers'
[I 16:20:16.695 NotebookApp] KernelRestarter: restarting kernel (3/5)
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/opt/root/root-6.08.06/lib/JupyROOT/__init__.py", line 1, in <module>
    import JupyROOT.utils
  File "/opt/root/root-6.08.06/lib/JupyROOT/utils.py", line 17, in <module>
    import handlers
ModuleNotFoundError: No module named 'handlers'
[W 16:20:17.690 NotebookApp] Timeout waiting for kernel_info reply from cc450642-22d6-42ee-a051-d423d774b5ae
[I 16:20:19.700 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel cc450642-22d6-42ee-a051-d423d774b5ae restarted
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/opt/root/root-6.08.06/lib/JupyROOT/__init__.py", line 1, in <module>
    import JupyROOT.utils
  File "/opt/root/root-6.08.06/lib/JupyROOT/utils.py", line 17, in <module>
    import handlers
ModuleNotFoundError: No module named 'handlers'
[W 16:20:22.708 NotebookApp] KernelRestarter: restart failed
[W 16:20:22.709 NotebookApp] Kernel cc450642-22d6-42ee-a051-d423d774b5ae died, removing from map.
ERROR:root:kernel cc450642-22d6-42ee-a051-d423d774b5ae restarted failed!
[W 16:20:22.729 NotebookApp] Kernel deleted before session
[W 16:20:22.730 NotebookApp] 410 DELETE /api/sessions/dc5030e2-1b46-431e-86be-69d2ec78bbed (::1) 1.33ms referer=http://localhost:8888/notebooks/Documents/Notebooks/Untitled.ipynb?kernel_name=root

(Also, does this belong in the ROOT Category?)

Thanks

Hi,

the category is fine, don’t worry.
Is this a binary distribution of ROOT? It looks like a Py3/Py2 issue. We distribute for the moment only Python2 based binaries which are not compatible with systems with only Python3 available.

Cheers,
D

1 Like

This is a compiled version of ROOT. Ahh that would explain it. I will try a the python 2 version.

It looks like I have the same issue with the python 2.7 version:

[I 16:10:52.407 NotebookApp] Kernel started: 077aade3-5222-45ed-aa62-9f34ef84437c
[W 16:10:52.422 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20170412161045 (::1) 8.46ms referer=http://localhost:8889/notebooks/Untitled.ipynb?kernel_name=root
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 163, in _run_module_as_main
    mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 102, in _get_module_details
    loader = get_loader(mod_name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 464, in get_loader
    return find_loader(fullname)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 474, in find_loader
    for importer in iter_importers(fullname):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 430, in iter_importers
    __import__(pkg)
  File "/opt/root/root-6.08.06/lib/JupyROOT/__init__.py", line 1, in <module>
    import JupyROOT.utils
  File "/opt/root/root-6.08.06/lib/JupyROOT/utils.py", line 17, in <module>
    import handlers
  File "/opt/root/root-6.08.06/lib/JupyROOT/handlers.py", line 16, in <module>
    _lib = CDLL("libJupyROOT.so")
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libJupyROOT.so, 6): image not found
[I 16:10:55.408 NotebookApp] KernelRestarter: restarting kernel (1/5)
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 163, in _run_module_as_main
    mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 102, in _get_module_details
    loader = get_loader(mod_name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 464, in get_loader
    return find_loader(fullname)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 474, in find_loader
    for importer in iter_importers(fullname):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 430, in iter_importers
    __import__(pkg)
  File "/opt/root/root-6.08.06/lib/JupyROOT/__init__.py", line 1, in <module>
    import JupyROOT.utils
  File "/opt/root/root-6.08.06/lib/JupyROOT/utils.py", line 17, in <module>
    import handlers
  File "/opt/root/root-6.08.06/lib/JupyROOT/handlers.py", line 16, in <module>
    _lib = CDLL("libJupyROOT.so")
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libJupyROOT.so, 6): image not found
[I 16:10:58.417 NotebookApp] KernelRestarter: restarting kernel (2/5)
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 163, in _run_module_as_main
    mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 102, in _get_module_details
    loader = get_loader(mod_name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 464, in get_loader
    return find_loader(fullname)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 474, in find_loader
    for importer in iter_importers(fullname):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 430, in iter_importers
    __import__(pkg)
  File "/opt/root/root-6.08.06/lib/JupyROOT/__init__.py", line 1, in <module>
    import JupyROOT.utils
  File "/opt/root/root-6.08.06/lib/JupyROOT/utils.py", line 17, in <module>
    import handlers
  File "/opt/root/root-6.08.06/lib/JupyROOT/handlers.py", line 16, in <module>
    _lib = CDLL("libJupyROOT.so")
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libJupyROOT.so, 6): image not found
[I 16:11:01.425 NotebookApp] KernelRestarter: restarting kernel (3/5)
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 163, in _run_module_as_main
    mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 102, in _get_module_details
    loader = get_loader(mod_name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 464, in get_loader
    return find_loader(fullname)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 474, in find_loader
    for importer in iter_importers(fullname):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 430, in iter_importers
    __import__(pkg)
  File "/opt/root/root-6.08.06/lib/JupyROOT/__init__.py", line 1, in <module>
    import JupyROOT.utils
  File "/opt/root/root-6.08.06/lib/JupyROOT/utils.py", line 17, in <module>
    import handlers
  File "/opt/root/root-6.08.06/lib/JupyROOT/handlers.py", line 16, in <module>
    _lib = CDLL("libJupyROOT.so")
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libJupyROOT.so, 6): image not found
[W 16:11:02.430 NotebookApp] Timeout waiting for kernel_info reply from 077aade3-5222-45ed-aa62-9f34ef84437c
[I 16:11:04.430 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 077aade3-5222-45ed-aa62-9f34ef84437c restarted
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 163, in _run_module_as_main
    mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 102, in _get_module_details
    loader = get_loader(mod_name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 464, in get_loader
    return find_loader(fullname)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 474, in find_loader
    for importer in iter_importers(fullname):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 430, in iter_importers
    __import__(pkg)
  File "/opt/root/root-6.08.06/lib/JupyROOT/__init__.py", line 1, in <module>
    import JupyROOT.utils
  File "/opt/root/root-6.08.06/lib/JupyROOT/utils.py", line 17, in <module>
    import handlers
  File "/opt/root/root-6.08.06/lib/JupyROOT/handlers.py", line 16, in <module>
    _lib = CDLL("libJupyROOT.so")
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libJupyROOT.so, 6): image not found
[W 16:11:07.436 NotebookApp] KernelRestarter: restart failed
[W 16:11:07.436 NotebookApp] Kernel 077aade3-5222-45ed-aa62-9f34ef84437c died, removing from map.
ERROR:root:kernel 077aade3-5222-45ed-aa62-9f34ef84437c restarted failed!
[W 16:11:07.466 NotebookApp] Kernel deleted before session
[W 16:11:07.466 NotebookApp] 410 DELETE /api/sessions/bb81979d-146e-4d86-8bfe-66a54056cf40 (::1) 1.84ms referer=http://localhost:8889/notebooks/Untitled.ipynb?kernel_name=root

Alright, that issue was with LD_LIBRARY_PATH. After resolving that I end up with this:

[I 16:16:11.122 NotebookApp] Creating new notebook in /Documents/Notebooks
[I 16:16:11.650 NotebookApp] Kernel started: 126afcb5-0784-414b-80aa-de3068119dc6
[W 16:16:11.665 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20170412161557 (::1) 7.78ms referer=http://localhost:8888/notebooks/Documents/Notebooks/Untitled1.ipynb?kernel_name=root
Fatal Python error: PyThreadState_Get: no current thread
[I 16:16:14.650 NotebookApp] KernelRestarter: restarting kernel (1/5)
Fatal Python error: PyThreadState_Get: no current thread
[I 16:16:17.658 NotebookApp] KernelRestarter: restarting kernel (2/5)
Fatal Python error: PyThreadState_Get: no current thread
[I 16:16:20.664 NotebookApp] KernelRestarter: restarting kernel (3/5)
Fatal Python error: PyThreadState_Get: no current thread
[W 16:16:21.671 NotebookApp] Timeout waiting for kernel_info reply from 126afcb5-0784-414b-80aa-de3068119dc6
[I 16:16:23.670 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 126afcb5-0784-414b-80aa-de3068119dc6 restarted
Fatal Python error: PyThreadState_Get: no current thread
[W 16:16:26.678 NotebookApp] KernelRestarter: restart failed
[W 16:16:26.678 NotebookApp] Kernel 126afcb5-0784-414b-80aa-de3068119dc6 died, removing from map.
ERROR:root:kernel 126afcb5-0784-414b-80aa-de3068119dc6 restarted failed!
[W 16:16:26.696 NotebookApp] Kernel deleted before session
[W 16:16:26.697 NotebookApp] 410 DELETE /api/sessions/1cf9e7fe-9c9f-4520-ba92-3a90cee33648 (::1) 1.75ms referer=http://localhost:8888/notebooks/Documents/Notebooks/Untitled1.ipynb?kernel_name=root

I appreciate the help.

The last issue was due to an incompatibility between apple’s python that ROOT was built with and the python version used by Jupyter installed by mac ports.

Recompiling ROOT with the macports Python required setting the following two environment variables to get cmake to complete the configuration:

export LC_ALL=en_US.UTF-8  
export LANG=en_US.UTF-8

I then need to install the metakernel package.

The notebook now starts correctly and was capable of drawing a simple histogram.

1 Like

Hi,

thanks for sharing all the steps you followed. This is now part of the forum as a future reference!

Cheers,
D

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.