Import ROOT fails in python

Hi,

I have a Linux Cebtos-8 PC where where I installed python3 and root like this:

dnf install python3 python3-devel
dnf install root

However, then I get an error trying to use root from within python:

Python 3.6.8 (default, Sep 21 2021, 20:17:36)
[GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘ROOT’

It looks like the root installation either misses the ROOT module for
python, or the python3 installation can not find it.

Now, the above ‘import ROOT’ does works on lxplus8, so I am likely missing
some more packages to be installed.

Could you please let me know?

Thanks and best regards

Martin

Hello,

Does it work if you run root from the command line?

If importing ROOT does not work right away after installing the package, you can locate the ROOT’s installation directory and execute source $ROOT_INST_DIR/bin/thisroot.sh.

Thanks for the reply!
Yes, the root command itself works and I get the root prompt. So the installation is there. Still what fails if I start python3 and then import ROOT at the python prompt.
The installation does not come with a thisroot.sh:
root-config --bindir
yields /usr/bin
but neither it nor /usr/share/root contains a thisroot.sh

Then it might be that ROOT was not installed for that Python version. Is there a Python2 installation? Does ROOT work with that one? I’d try to find where the ROOT Python modules were installed by dnf.

OK, the problem is solved if one also installs: dnf install python3-root.