PyROOT cannot be imported in ROOT6.32


ROOT Version: 6.32.02
Platform: Ubuntu 24.04
Compiler: c++ v13.2.0


Hi,
I just built the ROOT with Python 3.12.4 from conda environment. It built fine and running, other than the PyROOT. As in the following terminal output, I am getting a RuntimeError: could not load cppyy_backend library.

(base) saumyen@saumyen-ThinkPad-E14-Gen-6:~/HEP_Packages$ source root_install/bin/thisroot.sh 
(base) saumyen@saumyen-ThinkPad-E14-Gen-6:~/HEP_Packages$ root -q
   ------------------------------------------------------------------
  | Welcome to ROOT 6.32.02                        https://root.cern |
  | (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Jul 06 2024, 13:44:56                 |
  | From heads/master@tags/v6-32-02                                  |
  | With c++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0                        |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------


(base) saumyen@saumyen-ThinkPad-E14-Gen-6:~/HEP_Packages$ which python
/home/saumyen/HEP_Packages/miniconda3/bin/python
(base) saumyen@saumyen-ThinkPad-E14-Gen-6:~/HEP_Packages$ python -V
Python 3.12.4
(base) saumyen@saumyen-ThinkPad-E14-Gen-6:~/HEP_Packages$ python
Python 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 15:12:24) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import ROOT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/saumyen/HEP_Packages/root_install/lib/ROOT/__init__.py", line 25, in <module>
    import cppyy
  File "/home/saumyen/HEP_Packages/root_install/lib/cppyy/__init__.py", line 81, in <module>
    from ._cpython_cppyy import *
  File "/home/saumyen/HEP_Packages/root_install/lib/cppyy/_cpython_cppyy.py", line 21, in <module>
    c = loader.load_cpp_backend()
        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/saumyen/HEP_Packages/root_install/lib/cppyy_backend/loader.py", line 79, in load_cpp_backend
    raise RuntimeError("could not load cppyy_backend library")
RuntimeError: could not load cppyy_backend library
>>> 
(base) saumyen@saumyen-ThinkPad-E14-Gen-6:~/HEP_Packages$ cd root_install/
(base) saumyen@saumyen-ThinkPad-E14-Gen-6:~/HEP_Packages/root_install$ find -name 'libcppyy_backend*'
./lib/libcppyy_backend.so
(base) saumyen@saumyen-ThinkPad-E14-Gen-6:~/HEP_Packages/root_install$

Earlier, in Ubuntu 22.04.4 with c++ 11.4..0 and Python 3.10.12 from /usr/bin/python3.10 worked fine. Do you think the error is related to the Python version? The root --notebook command is also working. In the CMakeCache.txt I found these lines:

//Compiler reason failure
_Python3_Compiler_REASON_FAILURE:INTERNAL=
_Python3_DEVELOPMENT_EMBED_SIGNATURE:INTERNAL=7d39fa85bb138c83e9241639e4c23303
_Python3_DEVELOPMENT_MODULE_SIGNATURE:INTERNAL=12744826e38390a6903a1689ff0fe372
//Development reason failure
_Python3_Development_REASON_FAILURE:INTERNAL=
_Python3_EXECUTABLE:INTERNAL=/home/saumyen/HEP_Packages/miniconda3/bin/python3
//Path to a file.
_Python3_INCLUDE_DIR:INTERNAL=/home/saumyen/HEP_Packages/miniconda3/include/python3.12
//Python3 Properties
_Python3_INTERPRETER_PROPERTIES:INTERNAL=Python;3;12;4;64;;cpython-312-x86_64-linux-gnu;abi3;/home/saumyen/HEP_Packages/miniconda3/lib/python3.12;/home/saumyen/HEP_Packages/miniconda3/lib/python3.12;/home/saumyen/HEP_Packages/miniconda3/lib/python3.12/site-packages;/home/saumyen/HEP_Packages/miniconda3/lib/python3.12/site-packages
_Python3_INTERPRETER_SIGNATURE:INTERNAL=3d11cb787c0b3087f27520e3dc647fc4
//Interpreter reason failure
_Python3_Interpreter_REASON_FAILURE:INTERNAL=
//Path to a library.
_Python3_LIBRARY_RELEASE:INTERNAL=/home/saumyen/HEP_Packages/miniconda3/lib/libpython3.12.so
_Python3_NUMPY_SIGNATURE:INTERNAL=0f642a18a2ef2bf1386b75880aeead08
//Path to a file.
_Python3_NumPy_INCLUDE_DIR:INTERNAL=/home/saumyen/HEP_Packages/miniconda3/lib/python3.12/site-packages/numpy/core/include
//NumPy reason failure
_Python3_NumPy_REASON_FAILURE:INTERNAL=
__pkg_config_arguments_PKG_FONTCONFIG:INTERNAL=QUIET;fontconfig
__pkg_config_arguments__OPENSSL:INTERNAL=QUIET;openssl
__pkg_config_checked_DAVIX:INTERNAL=1
__pkg_config_checked_PC_LIBEDIT:INTERNAL=1
__pkg_config_checked_PC_LIBXML:INTERNAL=1
__pkg_config_checked_PC_SQLITE:INTERNAL=1
__pkg_config_checked_PKG_FONTCONFIG:INTERNAL=1
__pkg_config_checked__OPENSSL:INTERNAL=1

I will appreciate any possible help in this regard.

Regards,
Saumyen

Dear @Saumyenk ,

Thanks for reaching out to the forum!

Let me just start by pointing out that you do not need to build ROOT yourself, especially since you already use conda you can install ROOT in the conda environment directly (see Installing ROOT - ROOT).

Then, let’s see what could be the issue in your case. One possibility that comes to mind is that when configuring ROOT some environment variable was not properly setup or there was some leftover from another build. Could you also paste here the PYTHONPATH variable and maybe also upload the full CMakeCache.txt?

Cheers,
Vincenzo

Thanks a lot @vpadulan for the reply.

How to get the PYTHONPATH variable? I got this in the ROOTMacros.cmake file PYTHONPATH=${ROOTSYS}/lib:$ENV{PYTHONPATH}). I am attaching here the CMakeCache.txt.

Thanks and regards,
Saumyen

CMakeCache.txt (161.3 KB)

Dear @Saumyenk ,

I meant just pasting the value of the variable, as in echo $PYTHONPATH in your environment.

The CMakeCache file looks alright.

Can you also make sure that you have your libcppyy_backend.so located under your ${ROOTSYS}/lib path?

Cheers,
Vincenzo

Thanks @vpadulan for the reply.

I actually tried the command ‘echo $PYTHONPATH‘, it gave nothing. Now after sourcing the ROOT, I got that as /home/saumyen/HEP_Packages/root_install/lib.

I already checked if the libcppyy_backend.so is there as shown in the terminal output in the original question. It is there.

Thanks and regards,
Saumyen

Any idea from anybody?

Should I try to re-build with lower version of Python3?

Regards,

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