Libccppyy3_12 pyROOT problems

I have been trying to get pyROOT to work on my Mac (Ventura 13.6.7). Frustratingly, when I enter the python prompt by typing python3 then import ROOT I get some errors.

Python 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 10:14:12) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
/Volumes/Macintosh HD/Applications/root_v6.30.04/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 "/Volumes/Macintosh HD/Applications/root_v6.30.04/lib/cppyy/__init__.py", line 60, in <module>
    importlib.import_module(libcppyy_mod_name)
  File "/Users/benluke/anaconda3/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", 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 "<stdin>", line 1, in <module>
  File "/Volumes/Macintosh HD/Applications/root_v6.30.04/lib/ROOT/__init__.py", line 25, in <module>
    import cppyy
  File "/Volumes/Macintosh HD/Applications/root_v6.30.04/lib/cppyy/__init__.py", line 62, in <module>
    raise ImportError(
ImportError: Failed to import libcppyy3_12. Please check that ROOT has been built for Python 3.12

There have been several similar posts on the ROOT forum but none of their solutions have worked in my case. For reference, I am using ROOT 6.30.04, Xcode 15.2, and command line tools 15.1. Can anyone offer some wisdom?

[This post can be removed if desired by page managers… I am leaving my solution in case it is useful for others.]

I came to find out that the older version of ROOT I was using was not simultaneously compatible with the version of Python I was using, even though on ROOT’s page they say, “PyROOT is compatible with both Python2 (>= 2.7) and Python3.” This does not seem to be true in my experience. Once I created a Python environment with the appropriate version of Python, it no longer complained. (I found the Python version requirements by looking on the anaconda repository, finding my version of root, and clicking the information icon.)

Thanks for posting the problem you were facing and its solution: it enriched this knowledge base!

Cheers,
D

1 Like