scikit-hep / uproot5

ROOT I/O in pure Python and NumPy.

Home Page:https://uproot.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uproot (or fsspec_xrootd) looks for `libXrdCl.3.dylib` in the wrong directories

Saransh-cpp opened this issue · comments

Uproot errors out while opening root://eospublic.cern.ch//eos/root-eos/cms_opendata_2012_nanoaod/Run2012B_DoubleMuParked.root with the following stack trace:

>>> import uproot
>>> uproot.__version__
'5.2.1'
>>> filename = "root://eospublic.cern.ch//eos/root-eos/cms_opendata_2012_nanoaod/Run2012B_DoubleMuParked.root"
>>> file = uproot.open(filename)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~/Code/HEP/coffea/.env/lib/python3.11/site-packages/fsspec/registry.py in get_filesystem_class(protocol)
    235         try:
--> 236             register_implementation(protocol, _import_class(bit["class"]))
    237         except ImportError as e:

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/fsspec/registry.py in _import_class(cls, minv)
    270         s3 = mod == "s3fs"
--> 271         mod = importlib.import_module(mod)
    272         if s3 and mod.__version__.split(".") < ["0", "5"]:

/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py in import_module(name, package)
    125             level += 1
--> 126     return _bootstrap._gcd_import(name[level:], package, level)
    127 

/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/_bootstrap.py in _gcd_import(name, package, level)

/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/_bootstrap.py in _find_and_load(name, import_)

/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/_bootstrap.py in _load_unlocked(spec)

/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/_bootstrap_external.py in exec_module(self, module)

/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/fsspec_xrootd/__init__.py in <module>
     11 from ._version import version as __version__
---> 12 from .xrootd import XRootDFile, XRootDFileSystem
     13 

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/fsspec_xrootd/xrootd.py in <module>
     17 from fsspec.spec import AbstractBufferedFile  # type: ignore[import-not-found]
---> 18 from XRootD import client  # type: ignore[import-not-found]
     19 from XRootD.client.flags import (  # type: ignore[import-not-found]

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/XRootD/client/__init__.py in <module>
      2 
----> 3 from .glob_funcs import glob, iglob
      4 from .filesystem import FileSystem as FileSystem

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/XRootD/client/glob_funcs.py in <module>
     25 
---> 26 from XRootD.client.filesystem import FileSystem
     27 

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/XRootD/client/filesystem.py in <module>
     25 
---> 26 from pyxrootd import client
     27 from XRootD.client.responses import XRootDStatus, StatInfo, StatInfoVFS

ImportError: dlopen(/Users/saransh/Code/HEP/coffea/.env/lib/python3.11/site-packages/pyxrootd/client.cpython-311-darwin.so, 0x0002): Library not loaded: @rpath/libXrdCl.3.dylib
  Referenced from: <F808E69B-2BDA-3D93-B243-5E7E79525063> /Users/saransh/Code/HEP/coffea/.env/lib/python3.11/site-packages/pyxrootd/client.cpython-311-darwin.so
  Reason: tried: '/Users/saransh/Code/HEP/coffea/.env/lib/python3.11/site-packages/pyxrootd/../lib/libXrdCl.3.dylib' (no such file), '/Users/saransh/Code/HEP/coffea/.env/lib/python3.11/site-packages/pyxrootd/../lib/libXrdCl.3.dylib' (no such file), '/opt/homebrew/lib/libXrdCl.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libXrdCl.3.dylib' (no such file), '/opt/homebrew/lib/libXrdCl.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libXrdCl.3.dylib' (no such file)

The above exception was the direct cause of the following exception:

ImportError                               Traceback (most recent call last)
<ipython-input-4-73489904e2c3> in <cell line: 0>()
----> 1 file = uproot.open(filename)

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/uproot/reading.py in open(path, object_cache, array_cache, custom_classes, decompression_executor, interpretation_executor, **options)
    139         )
    140 
--> 141     file = ReadOnlyFile(
    142         file_path,
    143         object_cache=object_cache,

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/uproot/reading.py in __init__(self, file_path, object_cache, array_cache, custom_classes, decompression_executor, interpretation_executor, **options)
    557             file_path, self._options
    558         )
--> 559         self._source = source_cls(file_path, **self._options)
    560 
    561         self.hook_before_get_chunks()

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/uproot/source/fsspec.py in __init__(self, file_path, **options)
     29     def __init__(self, file_path: str, **options):
     30         super().__init__()
---> 31         self._fs, self._file_path = fsspec.core.url_to_fs(
     32             file_path, **self.extract_fsspec_options(options)
     33         )

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/fsspec/core.py in url_to_fs(url, **kwargs)
    381     }
    382     kwargs = {k: v for k, v in kwargs.items() if k not in known_kwargs}
--> 383     chain = _un_chain(url, kwargs)
    384     inkwargs = {}
    385     # Reverse iterate the chain, creating a nested target_* structure

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/fsspec/core.py in _un_chain(path, kwargs)
    330     for bit in reversed(bits):
    331         protocol = kwargs.pop("protocol", None) or split_protocol(bit)[0] or "file"
--> 332         cls = get_filesystem_class(protocol)
    333         extra_kwargs = cls._get_kwargs_from_urls(bit)
    334         kws = kwargs.pop(protocol, {})

~/Code/HEP/coffea/.env/lib/python3.11/site-packages/fsspec/registry.py in get_filesystem_class(protocol)
    236             register_implementation(protocol, _import_class(bit["class"]))
    237         except ImportError as e:
--> 238             raise ImportError(bit["err"]) from e
    239     cls = registry[protocol]
    240     if getattr(cls, "protocol", None) in ("abstract", None):

ImportError: Unable to load filesystem from EntryPoint(name='root', value='fsspec_xrootd:XRootDFileSystem', group='fsspec.specs')

Inspecting the first ImportError:

ImportError: dlopen(/Users/saransh/Code/HEP/coffea/.env/lib/python3.11/site-packages/pyxrootd/client.cpython-311-darwin.so, 0x0002): Library not loaded: @rpath/libXrdCl.3.dylib
  Referenced from: <F808E69B-2BDA-3D93-B243-5E7E79525063> /Users/saransh/Code/HEP/coffea/.env/lib/python3.11/site-packages/pyxrootd/client.cpython-311-darwin.so
  Reason: tried: '/Users/saransh/Code/HEP/coffea/.env/lib/python3.11/site-packages/pyxrootd/../lib/libXrdCl.3.dylib' (no such file), '/Users/saransh/Code/HEP/coffea/.env/lib/python3.11/site-packages/pyxrootd/../lib/libXrdCl.3.dylib' (no such file), '/opt/homebrew/lib/libXrdCl.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libXrdCl.3.dylib' (no such file), '/opt/homebrew/lib/libXrdCl.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libXrdCl.3.dylib' (no such file)

I think uproot is looking for libXrdCl.3.dylib in the wrong directories. The file is present in -

(.env) saransh@saranshmacair .env % ls lib/python3.11/site-packages/pyxrootd/ | grep libXrdCl.3.dylib
libXrdCl.3.dylib

I don't know if this is an uproot issue, a fsspec_xrootd issue, or an XRootD issue. This could also be an issue with my local setup. Any help would be appreciated, thank you!

At a glance I would say this is a problem with the xrootd installation not with fsspec-xrootd and definitely not with uproot.

Can you run xrootd directly (cli) to confirm this?

Could you please let me know the CLI command? I am very new to xrootd and its documentation has almost no straightforward examples.

At a glance I would say this is a problem with the xrootd installation not with fsspec-xrootd and definitely not with uproot.

I agree—can you install into a new environment and see if it's still an issue?

Created a new environment, definitely looks like a xrootd error -

>>> import uproot
>>> file = uproot.open("file://binder/Run2012B_DoubleMuParked.root")
>>> file = uproot.open("root://eospublic.cern.ch//eos/root-eos/cms_opendata_2012_nanoaod/Run2012B_DoubleMuParked.root")
Traceback (most recent call last):
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/fsspec/registry.py", line 236, in get_filesystem_class
    register_implementation(protocol, _import_class(bit["class"]))
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/fsspec/registry.py", line 271, in _import_class
    mod = importlib.import_module(mod)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/fsspec_xrootd/__init__.py", line 12, in <module>
    from .xrootd import XRootDFile, XRootDFileSystem
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/fsspec_xrootd/xrootd.py", line 18, in <module>
    from XRootD import client  # type: ignore[import-not-found]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/XRootD/client/__init__.py", line 3, in <module>
    from .glob_funcs import glob, iglob
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/XRootD/client/glob_funcs.py", line 26, in <module>
    from XRootD.client.filesystem import FileSystem
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/XRootD/client/filesystem.py", line 26, in <module>
    from pyxrootd import client
ImportError: dlopen(/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/pyxrootd/client.cpython-311-darwin.so, 0x0002): Library not loaded: @rpath/libXrdCl.3.dylib
  Referenced from: <F6155528-E476-321C-80E1-EAC70A48E0AA> /Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/pyxrootd/client.cpython-311-darwin.so
  Reason: tried: '/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/pyxrootd/../lib/libXrdCl.3.dylib' (no such file), '/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/pyxrootd/../lib/libXrdCl.3.dylib' (no such file), '/opt/homebrew/lib/libXrdCl.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libXrdCl.3.dylib' (no such file), '/opt/homebrew/lib/libXrdCl.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libXrdCl.3.dylib' (no such file)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/uproot/reading.py", line 141, in open
    file = ReadOnlyFile(
           ^^^^^^^^^^^^^
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/uproot/reading.py", line 559, in __init__
    self._source = source_cls(file_path, **self._options)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/uproot/source/fsspec.py", line 31, in __init__
    self._fs, self._file_path = fsspec.core.url_to_fs(
                                ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/fsspec/core.py", line 383, in url_to_fs
    chain = _un_chain(url, kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/fsspec/core.py", line 332, in _un_chain
    cls = get_filesystem_class(protocol)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/saransh/Code/HEP/coffea/env/lib/python3.11/site-packages/fsspec/registry.py", line 238, in get_filesystem_class
    raise ImportError(bit["err"]) from e
ImportError: Unable to load filesystem from EntryPoint(name='root', value='fsspec_xrootd:XRootDFileSystem', group='fsspec.specs')
(env) saransh@saranshmacair coffea % python3 -m pip freeze
awkward==2.5.2
awkward-cpp==28
fsspec==2023.12.2
fsspec-xrootd==0.2.4
importlib-metadata==7.0.1
numpy==1.26.3
packaging==23.2
uproot==5.2.1
xrootd==5.6.6
zipp==3.17.0

If possible, could you please let me know a standalone xrootd command through which I can reproduce this? I'll then create an issue on the GitHub repository.

Hi @Saransh-cpp!

Were you able to fix the installation issue?

I believe this is an installation error unrelated to uproot

I made a new conda environment with the same versions of packages you list in your environment and also I installed xrootd through conda: conda install xrootd==5.6.6

Both opening the file with uproot and copying locally work without any issues:

file = uproot.open("root://eospublic.cern.ch//eos/root-eos/cms_opendata_2012_nanoaod/Run2012B_DoubleMuParked.root")

xrdcp root://eospublic.cern.ch//eos/root-eos/cms_opendata_2012_nanoaod/Run2012B_DoubleMuParked.root .

This is an issue with the installation environment and not within uproot.

I will close this issue now.

Please comment if you think this should not have been closed and we will re-open the issue.

Hi @ioanaif,

Thanks for looking into this! Yes, definitely not an uproot issue. I still get the same error but moving the file around works. I might create an issue in xrootd.