Jupyter kernel failure during importing zmq

Root jupyter kernel fails with the following text:

Traceback (most recent call last):
  File "/home/user/git/root/root_install/lib/JupyROOT/kernel/rootkernel.py", line 22, in <module>
    from metakernel import MetaKernel
  File "/home/user/git/root/root_install/lib/ROOT/_facade.py", line 154, in _importhook
    return _orig_ihook(name, *args, **kwds)
  File "/home/user/.local/lib/python3.12/site-packages/metakernel/__init__.py", line 2, in <module>
    from ._metakernel import (
        ExceptionWrapper, MetaKernel, IPythonKernel, register_ipython_magics, get_metakernel,
        MetaKernelApp)
  File "/home/user/git/root/root_install/lib/ROOT/_facade.py", line 154, in _importhook
    return _orig_ihook(name, *args, **kwds)
  File "/home/user/.local/lib/python3.12/site-packages/metakernel/_metakernel.py", line 22, in <module>
    from ipykernel.kernelapp import IPKernelApp
  File "/home/user/git/root/root_install/lib/ROOT/_facade.py", line 154, in _importhook
    return _orig_ihook(name, *args, **kwds)
  File "/home/user/.local/lib/python3.12/site-packages/ipykernel/__init__.py", line 7, in <module>
    from .connect import *  # noqa: F403
    ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/git/root/root_install/lib/ROOT/_facade.py", line 154, in _importhook
    return _orig_ihook(name, *args, **kwds)
  File "/home/user/.local/lib/python3.12/site-packages/ipykernel/connect.py", line 12, in <module>
    import jupyter_client
  File "/home/user/git/root/root_install/lib/ROOT/_facade.py", line 154, in _importhook
    return _orig_ihook(name, *args, **kwds)
  File "/home/user/.local/lib/python3.12/site-packages/jupyter_client/__init__.py", line 3, in <module>
    from .asynchronous import AsyncKernelClient
  File "/home/user/git/root/root_install/lib/ROOT/_facade.py", line 154, in _importhook
    return _orig_ihook(name, *args, **kwds)
  File "/home/user/.local/lib/python3.12/site-packages/jupyter_client/asynchronous/__init__.py", line 1, in <module>
    from .client import AsyncKernelClient  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/git/root/root_install/lib/ROOT/_facade.py", line 154, in _importhook
    return _orig_ihook(name, *args, **kwds)
  File "/home/user/.local/lib/python3.12/site-packages/jupyter_client/asynchronous/client.py", line 8, in <module>
    import zmq.asyncio
  File "/home/user/git/root/root_install/lib/ROOT/_facade.py", line 154, in _importhook
    return _orig_ihook(name, *args, **kwds)
  File "/home/user/.local/lib/python3.12/site-packages/zmq/__init__.py", line 52, in <module>
    from zmq import backend
  File "/home/user/git/root/root_install/lib/ROOT/_facade.py", line 154, in _importhook
    return _orig_ihook(name, *args, **kwds)
  File "/home/user/.local/lib/python3.12/site-packages/zmq/backend/__init__.py", line 30, in <module>
    raise original_error from None
  File "/home/user/.local/lib/python3.12/site-packages/zmq/backend/__init__.py", line 25, in <module>
    _ns = select_backend(first)
  File "/home/user/.local/lib/python3.12/site-packages/zmq/backend/select.py", line 31, in select_backend
    mod = import_module(name)
  File "/usr/lib64/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.12/site-packages/zmq/backend/cython/__init__.py", line 6, in <module>
    from . import _zmq
  File "/home/user/git/root/root_install/lib/ROOT/_facade.py", line 154, in _importhook
    return _orig_ihook(name, *args, **kwds)
  File "/home/user/.local/lib/python3.12/site-packages/zmq/backend/cython/_zmq.py", line 14, in <module>
    raise ImportError("zmq Cython backend has not been compiled") from None
ImportError: zmq Cython backend has not been compiled

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/user/git/root/root_install/lib/JupyROOT/kernel/rootkernel.py", line 24, in <module>
    raise Exception("Error: package metakernel not found.(install it running 'pip install metakernel')")
Exception: Error: package metakernel not found.(install it running 'pip install metakernel')

Note that on a fresh install, from ipython import display fails. To get around this, i’ve added the default user pip directory to $PYTHONPATH.

After this change, the code can progress further but yields the error i copied above.

pyzmq and metakernel are installed, and importable from a python interpreter, however something goes wrong with imports done within ROOT code.


ROOT Version: 6.30/06
Built for linuxx8664gcc on May 29 2024, 00:19:30
From tags/v6.30.06-0-g4f4e716372@v6.30.06-0-g4f4e716372
Platform: Fedora 40


I will provide more information as requested - if i didnt provide something it is because of ignorance

Hello,

I just tried to import zmq on CERN’s jupyter platform, SWAN, and with ROOT 6.30.06 everything worked smoothly. Here you can find the list of packages available there: could you try to see if there is any inconsistency with your installation?

Best,
D

I cloned the source repository, followed the build instructions.
The root interpreter and everything around it works, however jupyter kernel throws the error i sent above.

If i was missing a dependency, there would be more concerning and obvious errors, such as the build failing

I managed to find the issue. root cmake detects python 3.13 but all packages are installed for python 3.12, which yields zmq cython compilation errors.

importing zmq from python3.13 did not work, and threw the same error. uninstalling python3.13 and rebuilding worked

1 Like

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