ImportError: Cannot load Graphbolt C++ library(DGL 2.2.0, PyTorch 2.2.2)

I’m facing a persistent OSError leading to ImportError: Cannot load Graphbolt C++ library when importing a library that uses DGL in a Conda environment on macOS. The error occurs during the loading of the DGL Graphbolt C++ shared library (.dylib).

  • OS: macOS (12.7.6 (21H1320))
  • Environment: Conda (Python 3.10)
  • Libraries: dgl==2.2.0, torch==2.2.2 (CPU), numpy==1.26.4

Steps Taken & Findings:

  1. Initial reinstallation of DGL/PyTorch did not fix it.
  2. Downgraded NumPy from 2.x to 1.26.4; NumPy warnings resolved, but DGL error persisted.
  3. Created a brand new, clean Conda environment, installed PyTorch (CPU, official), DGL (CPU, compatible version, official), NumPy (<2), and dependencies. Error still persists in the clean environment.
  4. Confirmed PyTorch core libraries (libc10.dylib, libtorch.dylib, libtorch_cpu.dylib) are present in the environment’s site-packages/torch/lib/.
  5. Ran otool -L on the problematic DGL Graphbolt library file (libgraphbolt_pytorch_2.2.2.dylib). Output shows dependencies on PyTorch libraries via @rpath and standard system libraries. No dependencies were explicitly marked as “not found” by otool -L.

Request:

Seeking assistance to diagnose and resolve this specific C++ library loading/linking issue.

Full Error Traceback:
--------------------------------------------------------------------------- OSError Traceback (most recent call last) File /opt/anaconda3/envs/aaai26/lib/python3.10/site-packages/dgl/graphbolt/init.py:31, in load_graphbolt() 30 try: —> 31 torch.classes.load_library(path) 32 except Exception: # pylint: disable=W0703 File /opt/anaconda3/envs/aaai26/lib/python3.10/site-packages/torch/_classes.py:51, in _Classes.load_library(self, path) 34 “”" 35 Loads a shared library from the given path into the current process. 36 (…) 49 path (str): A path to a shared library to load. 50 “”" —> 51 torch.ops.load_library(path) File /opt/anaconda3/envs/aaai26/lib/python3.10/site-packages/torch/_ops.py:933, in _Ops.load_library(self, path) 929 with dl_open_guard(): 930 # Import the shared library into the process, thus running its 931 # static (global) initialization code in order to register custom 932 # operators with the JIT. → 933 ctypes.CDLL(path) 934 self.loaded_libraries.add(path) File /opt/anaconda3/envs/aaai26/lib/python3.10/ctypes/init.py:374, in CDLL.init(self, name, mode, handle, use_errno, use_last_error, winmode)

31 torch.classes.load_library(path) 32 except Exception: # pylint: disable=W0703 —> 33 raise ImportError(“Cannot load Graphbolt C++ library”) ImportError: Cannot load Graphbolt C++ library