Installing Root to use PyRoot

Hi there,
I’m trying to install Root to use PyRoot and followed the instructions given on the website.
When I import Root I get the following error message:

>>> import ROOT
Traceback (most recent call last):
  File "/home/chiara/Desktop/root/lib/cppyy/__init__.py", line 60, in <module>
    importlib.import_module(libcppyy_mod_name)
  File "/home/chiara/anaconda3/envs/skymap/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'libcppyy3_10'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/chiara/Desktop/root/lib/ROOT/__init__.py", line 25, in <module>
    import cppyy
  File "/home/chiara/Desktop/root/lib/cppyy/__init__.py", line 62, in <module>
    raise ImportError(
ImportError: Failed to import libcppyy3_10. Please check that ROOT has been built for Python 3.10

I checked my python version:

python --version
Python 3.10.9

and checked this:

root-config --python3-version
3.6.8

So these versions don’t match. Could this be the problem? And if so, how do I fix this?

ROOT Version: 6.28/04
Platform: Ubuntu
Compiler: precompiled binary (I think? Sorry, I’m a total newbie to all of this)

If anyone can help, I would greatly appreciate it.
Cheers
Chiara

Dear @CJP ,

So these versions don’t match. Could this be the problem?

You are right indeed. In general, software you install in some environment must be used within that same environment.

So, the first question is, how did you install ROOT? I see some hints in your post, for example when you write

Compiler: precompiled binary (I think? Sorry, I’m a total newbie to all of this)

Links to precompiled binaries are available from Installing ROOT - ROOT . For 6.28/04, the full list is at Release 62804 - ROOT . So, did you download the ubuntu precompiled binary from here? In particular, there are three ubuntu versions supported from the list: 18, 20, 22. That also makes a big difference, you need that version to match your ubuntu version.

There are a lot of installation options at Installing ROOT - ROOT . One that might be a bit easier to manage is via conda . Once you create a new conda environment and you install ROOT in it, remember to always conda activate it. From within the activated conda environment, you should be able to use ROOT/PyROOT as you like.

Cheers,
Vincenzo

Thank you for the fast answer!

Yes, I tried to follow the instructions for ‘Download a pre-compiled binary distribution’ and went to ‘Download the release’ (I can’t post links as a new user so I hope this is clear).

But instead of actually downloading a binary distribution I followed the instructions for ‘Git’ which first seemed to work as well but I think that caused the problem or was at least part of the problem.

I tried the conda version but another issue came up so now I actually downloaded the ubuntu version 22 and the issue disappeared.

Thank you again
Chiara

1 Like