ImportError: Failed to import libcppyy3_8. Please check that ROOT has been built for Python 3.8

Hi, this is what I get when I try to import ROOT in python 3.8 on my macOS terminal

python3

Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18)
[Clang 6.0 (clang-600.0.57)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT

Traceback (most recent call last):
File “/Applications/root_v6.30.06/lib/cppyy/init.py”, line 60, in
importlib.import_module(libcppyy_mod_name)
File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1014, in _gcd_import
File “”, line 991, in _find_and_load
File “”, 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 “”, line 1, in
File “/Applications/root_v6.30.06/lib/ROOT/init.py”, line 25, in
import cppyy
File “/Applications/root_v6.30.06/lib/cppyy/init.py”, line 62, in
raise ImportError(
ImportError: Failed to import libcppyy3_8. Please check that ROOT has been built for Python 3.8


Please read tips for efficient and successful posting and posting code

Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.

ROOT Version:6.30.05
Platform: MacOS 14.4.1

This is what I get in python 3.12.2

import ROOT

/Applications/root_v6.30.06/lib/cppyy/init.py:72: SyntaxWarning: invalid escape sequence ‘\d’
if re.match(‘^libcppyy_backend\d+_\d+$’, lib_name):
Traceback (most recent call last):
File “/Applications/root_v6.30.06/lib/cppyy/init.py”, line 60, in
importlib.import_module(libcppyy_mod_name)
File “/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/init.py”, line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “”, line 1387, in _gcd_import
File “”, line 1360, in _find_and_load
File “”, line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘libcppyy3_12’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “”, line 1, in
File “/Applications/root_v6.30.06/lib/ROOT/init.py”, line 25, in
import cppyy
File “/Applications/root_v6.30.06/lib/cppyy/init.py”, line 62, in
raise ImportError(
ImportError: Failed to import libcppyy3_12. Please check that ROOT has been built for Python 3.12

solved by

pip install cppyy

as suggested by chatGPT

Hi Eric,

Glad the mix works (maybe Xrootd with TChain - #2 by Danilo). How did you install ROOT?

Cheers,
D

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