ModuleNotFoundError: No module named 'ROOT' --- on RHEL UBI8

ROOT Version:

ROOT Version: 6.26/06
Built for linuxx8664gcc on Jul 28 2022, 18:08:51
From tags/v6-26-06@v6-26-06

Platform: RHEL UBI8
Compiler: Not Provided

I am creating a custom Python3.8 RHEL UBI8 image with a root installation, but I cannot access the ROOT module from within python3, getting the usual:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ROOT'

I am installing root from EPEL using dnf like so:

dnf install -y epel-release \
&& dnf install -y root python3-root 

Some extra info:

  • I can run root normally from the terminal.
  • Python installed is Python 3.8.3
  • There are no files (except for a README.txt) in /usr/lib64/python3.8/site-packages/
  • root-config --has-pyroot returns yes
  • root-config --features returns:
    cxx14 asimage builtin_clang builtin_cling builtin_llvm builtin_openui5 dataframe davix dcache exceptions fftw3 fitsio fortran gdml gfal gnuinstall gsl_shared gviz http fcgi imt mathmore mlp minuit2 mysql odbc opengl pgsql pyroot pythia8 qt5web r roofit webgui shadowpw shared soversion sqlite ssl tmva tmva-cpu tmva-sofie tmva-pymva tmva-rmva spectrum unuran x11 xml xrootd
  • Running root-config --python-version or root-config --python3-version returns 3.6.8 (different from the system’s one!)
  • root is installed in /usr/bin/root. There’s no file as expected for OS-installed root as explained in another thread.
  • There are no files in /usr/local/bin

Other things I’ve tried:

I’m available for any extra info required.

Thanks in advance!

The ROOT Team provides ready-to-use binary distributions for some systems (see “Download a pre-compiled binary distribution” therein), including various CentOS versions, which you just need to download and unpack.

For CentOS 8 / x86_64 / gcc 8.5:;O=A;P=*[cC][eE][nN][tT][oO][sS]8*

1 Like

Thanks for this info!

I tried it with root_v6.26.08.Linux-centos8-x86_64-gcc8.5.tar.gz (the seemingly latest one) and followed the instructions:

  • wget the archive.
  • tar -xzfv it
  • source the file

And when I run root-config --python3-version I still get 3.6.8. Am I missing something?

PS: I made sure that which root-config points to the untared directory.

Make sure you completely remove ALL ROOT related packages that you installed earlier (with dnf).

I’m using a clean UBI8 image now, without any extra packages installed, i.e. I’m not running any dnf commands in my Dockerfile. The only root-related files are the ones I get from wget.

Also, I’m getting this error now when importing:

>>> import ROOT
Traceback (most recent call last):
  File "/opt/app-root/src/root/root/lib/cppyy/", line 60, in <module>
  File "/usr/lib64/python3.8/importlib/", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'libcppyy3_8'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/app-root/src/root/root/lib/ROOT/", line 22, in <module>
    import cppyy
  File "/opt/app-root/src/root/root/lib/cppyy/", line 62, in <module>
    raise ImportError(
ImportError: Failed to import libcppyy3_8. Please check that ROOT has been built for Python 3.8

Which seems more descriptive.

I’ve also installed all dependencies listed here.

In summary:

  1. Using a Dockerfile, I start from a Python3.8 UBI8 image, in which I install dependencies listed on the root installation page (dnf install -y make cmake gcc-c++ gcc binutils libX11-devel libXpm-devel libXft-devel libXext-devel python3-root)
  2. I connect to the created container and I verify that which root does not find a root installation.
  3. I then follow the procedure to:
    • wget the root_v6.26.08.Linux-centos8-x86_64-gcc8.5.tar.gz file from within the created container.
    • tar -xzfv it
    • source the file in the extracted directory.
    • Verify that root --version returns ROOT Version: 6.26/08 and which root and which root-config return the correct paths inside the extracted files.
  4. root-config --python3-version still returns 3.6.8
  5. In python3:
    import ROOT
    ModuleNotFoundError: No module named 'libcppyy3_8'

Do NOT install “python3-root”.

Just retried, without python3-root this time, only:

make cmake gcc-c++ gcc binutils libX11-devel libXpm-devel libXft-devel libXext-devel

Unfortunately, same behavior.

@Axel and / or @etejedor


The error message above indicates that the ROOT installation you are trying to use has not been built for Python3.8.

Would conda be an option for you? It is usually the easiest solution to avoid this kind of conflicts:

@nothingface0 From the first post, your default Python version seems to be “Python 3.8.3”.

However, I have now found two different machines which run “CentOS Stream release 8” and “Rocky Linux release 8.6 (Green Obsidian)”, and both of them provide “Python 2.7.18” and “Python 3.6.8” (to my surprise, the same as on old CentOS 7 / RHEL 7).

So, try: find ${ROOTSYS} -name "libcppyy*.so"

1 Like

To know for sure, you can search for in the ROOT installation directory. If it exists, I would try to import it alone import libcppyy3_8.

The result of find ${ROOTSYS} -name "libcppyy*.s is:

(app-root) sh-4.4$ find ${ROOTSYS} -name "libcppyy*.so" 

Where ./root is the directory where root_v6.26.08.Linux-centos8-x86_64-gcc8.5.tar.gz is extracted.

To make sure I understand, is there no precompiled binary for centos8 which is built for Python 3.8?

Maybe there is some “LCG release on CVMFS”.

Thanks for the pointer, I’ll try this and let you know :slight_smile:

I did not find one, after all. I ended up building from source.

I still don’t understand if there is a precompiled binary compatible with my setup.

Thanks again for the help.

Hi @nothingface0 ,

I don’t think we have pre-compiled binaries or LCG releases explicitly for RHEL, so I guess you can either try your luck with builds meant for CentOS or (probably safer) build from source as you did.


Hello! I tried using CentOS8 binaries which work for RHEL8, but, as you can see above, they are all compiled for Python 3.6, while I’m using Python 3.8, so I cannot run import ROOT.

Anyway, although tedious, building from source ended up solving the problem.

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