PyROOT does not work anymore?

Hello,

Just compiled ROOT 6.38.
Seems like PyROOT is not working anymore?


$ python3
Python 3.13.0 (v3.13.0:60403a5409f, Oct  7 2024, 00:37:40) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import ROOT
  File "/Users/USR/soft/root_install/lib/ROOT/__init__.py", line 20, in <module>
    import cppyy
  File "/Users/USR/soft/root_install/lib/cppyy/__init__.py", line 74, in <module>
    from ._cpython_cppyy import *
  File "/Users/USR/soft/root_install/lib/cppyy/_cpython_cppyy.py", line 27, in <module>
    c = loader.load_cpp_backend()
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cppyy_backend/loader.py", line 92, in load_cpp_backend
    raise RuntimeError("could not load cppyy_backend library, details:\n%s" %
        '\n'.join(['  '+x for x in err]))
RuntimeError: could not load cppyy_backend library, details:
  dlopen(/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cppyy_backend/lib/libcppyy_backend.so, 0x000A): tried: '/Users/USR/soft/root_install/lib/libcppyy_backend.so' (no such file), '/Users/USR/soft/root_install/lib/libcppyy_backend.so' (no such file), '/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cppyy_backend/lib/libcppyy_backend.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cppyy_backend/lib/libcppyy_backend.so' (no such file), '/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cppyy_backend/lib/libcppyy_backend.so' (no such file)
  dlopen(libcppyy_backend.cpython-313-darwin.so, 0x000A): tried: '/Users/USR/soft/root_install/lib/libcppyy_backend.cpython-313-darwin.so' (no such file), '/Users/USR/soft/root_install/lib/libcppyy_backend.cpython-313-darwin.so' (no such file), 'libcppyy_backend.cpython-313-darwin.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcppyy_backend.cpython-313-darwin.so' (no such file), '/usr/lib/libcppyy_backend.cpython-313-darwin.so' (no such file, not in dyld cache), 'libcppyy_backend.cpython-313-darwin.so' (no such file), '/usr/local/lib/libcppyy_backend.cpython-313-darwin.so' (no such file), '/libcppyy_backend.cpython-313-darwin.so' (no such file)
  dlopen(/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so, 0x000A): tried: '/Users/USR/soft/root_install/lib/libcppyy_backend.cpython-313-darwin.so' (no such file), '/Users/USR/soft/root_install/lib/libcppyy_backend.cpython-313-darwin.so' (no such file), '/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so' (no such file), '/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so' (no such file)
  dlopen(libcppyy_backend.so, 0x000A): tried: '/Users/USR/soft/root_install/lib/libcppyy_backend.so' (no such file), '/Users/USR/soft/root_install/lib/libcppyy_backend.so' (no such file), 'libcppyy_backend.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcppyy_backend.so' (no such file), '/usr/lib/libcppyy_backend.so' (no such file, not in dyld cache), 'libcppyy_backend.so' (no such file), '/usr/local/lib/libcppyy_backend.so' (no such file), '/libcppyy_backend.so' (no such file)

ROOT Version: 6.38.00
Platform: macOS


root-config --python-version

$ root-config --python-version
3.13.0

Removed 6.38, installed latest 6.36.
Import works.

But when moving to scripts, like in one of the previous threads, shebang #!/usr/bin/env python3 still not working. Only #!/usr/local/bin/python3 works.

$ cat test_usrlocal.py
#!/usr/local/bin/python3

import ROOT

$ cat test_usrbinenv.py
#!/usr/bin/env python3

import ROOT



$ ./test_usrlocal.py
$ ./test_usrbinenv.py
Traceback (most recent call last):
  File "/Users/USR/test_ccppy/./test_usrbinenv.py", line 3, in <module>
    import ROOT
  File "/Users/USR/soft/root_install/lib/ROOT/__init__.py", line 25, in <module>
    import cppyy
  File "/Users/USR/soft/root_install/lib/cppyy/__init__.py", line 88, in <module>
    from ._cpython_cppyy import *
  File "/Users/USR/soft/root_install/lib/cppyy/_cpython_cppyy.py", line 24, in <module>
    c = loader.load_cpp_backend()
  File "/Users/USR/soft/root_install/lib/cppyy_backend/loader.py", line 100, in load_cpp_backend
    raise RuntimeError("could not load cppyy_backend library, details:\n%s" %
        '\n'.join(['  '+x for x in err]))
RuntimeError: could not load cppyy_backend library, details:
  dlopen(/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so, 0x000A): tried: '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so' (no such file), '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so' (no such file)
  dlopen(/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so, 0x000A): tried: '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so' (no such file), '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so' (no such file)
  dlopen(libcppyy_backend.cpython-313-darwin.so, 0x000A): tried: 'libcppyy_backend.cpython-313-darwin.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcppyy_backend.cpython-313-darwin.so' (no such file), '/usr/lib/libcppyy_backend.cpython-313-darwin.so' (no such file, not in dyld cache), 'libcppyy_backend.cpython-313-darwin.so' (no such file)
  dlopen(libcppyy_backend.so, 0x000A): tried: 'libcppyy_backend.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcppyy_backend.so' (no such file), '/usr/lib/libcppyy_backend.so' (no such file, not in dyld cache), 'libcppyy_backend.so' (no such file)

which -a python3
type -a python3

$ which -a python3
/Library/Frameworks/Python.framework/Versions/3.13/bin/python3
/usr/local/bin/python3
/opt/homebrew/bin/python3
/usr/local/bin/python3
/usr/bin/python3
$ type -a python3
python3 is /Library/Frameworks/Python.framework/Versions/3.13/bin/python3
python3 is /usr/local/bin/python3
python3 is /opt/homebrew/bin/python3
python3 is /usr/local/bin/python3
python3 is /usr/bin/python3

Problem was already here: Libcppyy_backend.so: cannot open shared object file: No such file or directory - #9 by StephanH

Python interpreter is always the official one: /Library/Frameworks/Python.framework/Versions/3.13/bin/python3

What happens when you use:
#!/Library/Frameworks/Python.framework/Versions/3.13/bin/python3
and (“/usr/bin/python3 --version” returns 3.13.0?):
#!/usr/bin/python3

#!/Library/Frameworks/Python.framework/Versions/3.13/bin/python3

‘import ROOT’ works without errors

and (“/usr/bin/python3 --version ” returns 3.13.0 ?):

No, this is macOS system Python (3.9.6).
However, it is not loaded.

I modified test scripts to show the interpreter info:

$ cat test_usrbinenv.py
#!/usr/bin/env python3

import sys
print(sys.version)

import ROOT
$ ./test_usrbinenv.py
3.13.0 (v3.13.0:60403a5409f, Oct  7 2024, 00:37:40) [Clang 15.0.0 (clang-1500.3.9.4)]
Traceback (most recent call last):
  File "/Users/USR/test_ccppy/./test_usrbinenv.py", line 6, in <module>
    import ROOT
  File "/Users/USR/soft/root_install/lib/ROOT/__init__.py", line 25, in <module>
    import cppyy
  File "/Users/USR/soft/root_install/lib/cppyy/__init__.py", line 88, in <module>
    from ._cpython_cppyy import *
  File "/Users/USR/soft/root_install/lib/cppyy/_cpython_cppyy.py", line 24, in <module>
    c = loader.load_cpp_backend()
  File "/Users/USR/soft/root_install/lib/cppyy_backend/loader.py", line 100, in load_cpp_backend
    raise RuntimeError("could not load cppyy_backend library, details:\n%s" %
        '\n'.join(['  '+x for x in err]))
RuntimeError: could not load cppyy_backend library, details:
  dlopen(libcppyy_backend.cpython-313-darwin.so, 0x000A): tried: 'libcppyy_backend.cpython-313-darwin.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcppyy_backend.cpython-313-darwin.so' (no such file), '/usr/lib/libcppyy_backend.cpython-313-darwin.so' (no such file, not in dyld cache), 'libcppyy_backend.cpython-313-darwin.so' (no such file)
  dlopen(/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so, 0x000A): tried: '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so' (no such file), '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-313-darwin.so' (no such file)
  dlopen(/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so, 0x000A): tried: '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so' (no such file), '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so' (no such file)
  dlopen(libcppyy_backend.so, 0x000A): tried: 'libcppyy_backend.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcppyy_backend.so' (no such file), '/usr/lib/libcppyy_backend.so' (no such file, not in dyld cache), 'libcppyy_backend.so' (no such file)

When using explicitly the old system Python 3.9.6:

$ cat test_usrbinpython.py
#!/usr/bin/python3

import sys
print(sys.version)

import ROOT
$ ./test_usrbinpython.py
3.9.6 (default, Oct 17 2025, 17:15:53)
[Clang 17.0.0 (clang-1700.4.4.1)]
Traceback (most recent call last):
  File "/Users/USR/test_ccppy/./test_usrbinpython.py", line 6, in <module>
    import ROOT
  File "/Users/USR/soft/root_install/lib/ROOT/__init__.py", line 25, in <module>
    import cppyy
  File "/Users/USR/soft/root_install/lib/cppyy/__init__.py", line 88, in <module>
    from ._cpython_cppyy import *
  File "/Users/USR/soft/root_install/lib/cppyy/_cpython_cppyy.py", line 24, in <module>
    c = loader.load_cpp_backend()
  File "/Users/USR/soft/root_install/lib/cppyy_backend/loader.py", line 100, in load_cpp_backend
    raise RuntimeError("could not load cppyy_backend library, details:\n%s" %
RuntimeError: could not load cppyy_backend library, details:
  dlopen(/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-39-darwin.so, 0x000A): tried: '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-39-darwin.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-39-darwin.so' (no such file), '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.cpython-39-darwin.so' (no such file)
  dlopen(/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so, 0x000A): tried: '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so' (no such file), '/Users/USR/soft/root_install/lib/cppyy_backend/lib/libcppyy_backend.so' (no such file)
  dlopen(libcppyy_backend.cpython-39-darwin.so, 0x000A): tried: 'libcppyy_backend.cpython-39-darwin.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcppyy_backend.cpython-39-darwin.so' (no such file), '/usr/lib/libcppyy_backend.cpython-39-darwin.so' (no such file, not in dyld cache), 'libcppyy_backend.cpython-39-darwin.so' (no such file)
  dlopen(libcppyy_backend.so, 0x000A): tried: 'libcppyy_backend.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcppyy_backend.so' (no such file), '/usr/lib/libcppyy_backend.so' (no such file, not in dyld cache), 'libcppyy_backend.so' (no such file)

So, it looks for different libraries.

Well, assuming that the problem is related to LD_LIBRARY_PATH or DYLD_LIBRARY_PATH, try:
#!/usr/bin/env LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}" python3

This does not work.

However, tried also this:

$ export DYLD_LIBRARY_PATH=${LD_LIBRARY_PATH}

$ echo $DYLD_LIBRARY_PATH
/Users/USR/soft/root_install/lib:/usr/local/lib::/opt/homebrew/lib

So, $DYLD_LIBRARY_PATH is set now. Then:

$ cat test_usrbinenv.py
#!/usr/bin/env python3

import sys
print(sys.version)

import os
ld_library_path = os.getenv('LD_LIBRARY_PATH', 'LD_LIBRARY_PATH not set')
print(f'LD_LIBRARY_PATH: {ld_library_path}')
dyld_library_path = os.getenv('DYLD_LIBRARY_PATH', 'DYLD_LIBRARY_PATH not set')
print(f'DYLD_LIBRARY_PATH: {dyld_library_path}')

import ROOT

When running macro $DYLD_LIBRARY_PATH is not used:

$ ./test_usrbinenv.py
3.13.0 (v3.13.0:60403a5409f, Oct  7 2024, 00:37:40) [Clang 15.0.0 (clang-1500.3.9.4)]
LD_LIBRARY_PATH: /Users/USR/soft/root_install/lib:/usr/local/lib::/opt/homebrew/lib
DYLD_LIBRARY_PATH: DYLD_LIBRARY_PATH not set
Traceback (most recent call last):
  ...
Same error as before
  ...

Seems like PyROOT depends heavily on $DYLD_LIBRARY_PATH.

I found this link: Runtime Protections

Any dynamic linker (dyld ) environment variables, such as DYLD_LIBRARY_PATH , are purged when launching protected processes.

Is it related?

Dear @vkireyeu ,

Thanks for reaching out to the forum!

At the cost of sounding naive, are you sure you need to compile ROOT from scratch? I understand you’re using 6.38.00 which was released less than 48 hours ago, but very soon you’ll be able to install it via conda or probably also via brew. Unless you require custom modifications of ROOT, it would be way easier to wait a few more days and install it via one of the distributions.

Cheers,
Vincenzo

Hello,

So, the problem is, unfortunately, that due to Apple SIP DYLD_LIBRARY_PATH cannot be used by ROOT anymore, so, the shebang must be modified for ROOT 6.36.
ROOT (PyROOT) 6.38 does not work at all.
Will conda/brew really be a fix for it?

ROOT always (from my experience) compiled and worked very well on macOS without any crutches and supports (it is even shipped with some needed dependencies). So I would like to stick with normal ROOT installation procedure as long as it is possible.

Conda/brew are attempts to simulate something close to linux package managements for macOS, but both are miserable from my experience and I’d prefer to avoid using conda at all costs.

Try:
export PATH=/usr/local/bin:${PATH}

Dear @vkireyeu ,

I am sorry to hear about your less than ideal experience. I am still a bit puzzled by your description. The ROOT project constantly builds on MacOS, every PR, every night the source is built for MacOS14,15,26 and beta, on x86-64 and ARM64. Not only it compiles well, but the full battery of tests and tutorials is run and checked constantly. So, I would say that ROOT is definitely still compiling and working well on MacOS, for all intents and purposes. What may be left to understand is what is different on your particular machine/environment or the way you setup the build.

Cheers,

Vincenzo