Import Error

Dear ROOT,

I have encountered the following error:

  Referenced from: /opt/local/libexec/root6/lib/root/libcppyy3_10.6.26.00.so
  Reason: image not found

The problem is that this .so file is actually present on my system so I don’t know what’s going on here. I’m hoping that you can provide me with some insight on this matter.

Many Thanks

Rob

ROOT Version: 6.26/00 via Macports
Platform: Big Sur (MacOS), MacBook Pro with M1/ARM processor.
compiler: gcc11 11.2.0_1

This is a completely fresh macports. I’ve installed root6 and it doesn’t work in python and I get the following error.

I only have python 3.10 as it is a dependancy of the root 6 port.

In [1]: import ROOT
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File /opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cppyy/__init__.py:60, in <module>
     59 try:
---> 60     importlib.import_module(libcppyy_mod_name)
     61 except ImportError:

File /opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
    125         level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1050, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1027, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1006, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:674, in _load_unlocked(spec)

File <frozen importlib._bootstrap>:571, in module_from_spec(spec)

File <frozen importlib._bootstrap_external>:1176, in create_module(self, spec)

File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)

ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/libcppyy3_10.so, 2): Library not loaded: @rpath/libcppyy_backend3_10.6.26.so
  Referenced from: /opt/local/libexec/root6/lib/root/libcppyy3_10.6.26.00.so
  Reason: image not found

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
Input In [1], in <module>
----> 1 import ROOT

File /opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ROOT/__init__.py:22, in <module>
     19 # Prevent cppyy from filtering ROOT libraries
     20 environ['CPPYY_NO_ROOT_FILTER'] = '1'
---> 22 import cppyy
     23 if not 'ROOTSYS' in environ:
     24     # Revert setting made by cppyy
     25     cppyy.gbl.gROOT.SetBatch(False)

File /opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cppyy/__init__.py:62, in <module>
     60     importlib.import_module(libcppyy_mod_name)
     61 except ImportError:
---> 62     raise ImportError(
     63             'Failed to import {}. Please check that ROOT has been built for Python {}.{}'.format(
     64                 libcppyy_mod_name, major, minor))
     66 # ensure 'import libcppyy' will find the versioned module
     67 sys.modules['libcppyy'] = sys.modules[libcppyy_mod_name]

ImportError: Failed to import libcppyy3_10. Please check that ROOT has been built for Python 3.10

port installed | grep root
root6 @6.26.00_0+cocoa+davix+gccdevel+graphviz+gsl+opengl+python310+roofit+tmva+xml+xrootd (active)
root_select @1.3_0 (active)
xrootd @5.4.2_0+kerberos+python310+readline+ssl (active)

Thanks for your time

Welcome to the ROOT Forum! I think @etejedor can help with this

Hello,

Can you check for what Python version your ROOT was built for?

In particular, by running:

root-config --python-version
root-config --python3-version
root-config --python2-version

Hello,

rob-mac:~ robmac$ root-config --python-version
3.10.2
rob-mac:~ robmac$ root-config --python3-version
3.10.2
rob-mac:~ robmac$ root-config --python2-version

There wasn’t anything returned for --python2-version.

I hope that this is useful.

Thanks

The python version your ROOT was built with and the one that you are using seem to be the same (3.10), so I don’t know what the problem is.

@jonesc might know?

Otherwise, I’d propose that you try an alternative way of installation ROOT, e.g. conda:

I see the same with the macPorts installation. I’ll look into it when I can…

I just pushed an update to MacPorts that addresses this (and updates to 6.26.02 at the same time).

Issue appears to be that the root build is not correctly setting the @rpath entries in some binaries for the final installation path. I cannot say if this is a bug in the root build system, triggered by the specific build options we use in MacPorts, or just a but on the MacPorts side, but I am leaning towards the former.

In any case I’ve added a workaround to the MacPorts build to manually run install_name_tool to add the required @rpath entries to the binaries that are missing them.

2 Likes

Dear ROOT Devs,

I’m not getting any import ROOT errors in python anymore.

Thank you very much for your help.

Rob

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