PyROOT cannot be imported in ROOT6.32

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

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/ 
(base) saumyen@saumyen-ThinkPad-E14-Gen-6:~/HEP_Packages$ root -q
  | Welcome to ROOT 6.32.02               |
  | (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
(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/", line 25, in <module>
    import cppyy
  File "/home/saumyen/HEP_Packages/root_install/lib/cppyy/", line 81, in <module>
    from ._cpython_cppyy import *
  File "/home/saumyen/HEP_Packages/root_install/lib/cppyy/", line 21, in <module>
    c = loader.load_cpp_backend()
  File "/home/saumyen/HEP_Packages/root_install/lib/cppyy_backend/", 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*'
(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
//Development reason failure
//Path to a file.
//Python3 Properties
//Interpreter reason failure
//Path to a library.
//Path to a file.
//NumPy reason failure

I will appreciate any possible help in this regard.


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?


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,

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 located under your ${ROOTSYS}/lib path?


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 is there as shown in the terminal output in the original question. It is there.

Thanks and regards,

Any idea from anybody?

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