Fail to import ROOT in python on MAC OS

Hello,

I installed the latest root version using the “root_v6.26.06.macos-12.5-x86_64-clang131.pkg”. It’s installed successfully. But when I try to do “import ROOT” in python3, I got the following error messages:

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

root-config --python-version gives: 3.8.9
My python3 gives:
‘Python 3.8.9 (default, Apr 13 2022, 08:48:06)
[Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin’

I’m not sure why it complains the versions are not matching.

_ROOT Version:_6.26.06
Platform: MacOS 12.5.1
Compiler: Not Provided


There is some similar question on the forum like: Pyroot through macports broken - #5 by eguiraud > Use the search box to find more. Otherwise @etejedor may have an idea.

Hello,

Can you try import libcppyy3_8 and check what message it gives?

    import libcppyy3_8
ImportError: dlopen(/Applications/root_v6.26.06/lib/libcppyy3_8.so, 0x0002): tried: '/Applications/root_v6.26.06/lib/libcppyy3_8.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))), '/Applications/root_v6.26.06/lib/libcppyy3_8.6.26.06.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))

Installing " [root_v6.26.06.macos-12.4-arm64-clang131.pkg]" solved the issue.

Thanks!

1 Like

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