Problem loading libPyROOT in ROOT

Hi,

after having read through
[url]PyROOT issues on OS X 10.11 (El Capitan)
I have concluded that I have somewhat of the inverse problem.

I run MacOs Yosemite with Enthought Python 2.7 and ROOT 5-34-34.

I have no issues running import ROOT in python (everything works nicely there), however, when trying to load the lib in ROOT, I get:

[code].L $ROOTSYS/lib/libPyROOT.so

dlopen error: dlopen(/Users/anelles/Software/root/lib/libPyROOT.so, 9): Library not loaded: @rpath/Python
Referenced from: /Users/anelles/Software/root/lib/libPyROOT.so
Reason: no suitable image found. Did find:
/Users/anelles/Software/root/lib/Python: not a file
Load Error: Failed to load Dynamic link library /Users/anelles/Software/root/lib/libPyROOT.so[/code]

To me this looks like the @rpath variable tries to find Python in the ROOT path, where it should be looking at something from python.

The output of

otool -L lib/libPyROOT.so lib/libPyROOT.so: @rpath/libPyROOT.so (compatibility version 0.0.0, current version 0.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0) @rpath/libCore.so (compatibility version 0.0.0, current version 0.0.0) @rpath/libCint.so (compatibility version 0.0.0, current version 0.0.0) @rpath/libRIO.so (compatibility version 0.0.0, current version 0.0.0) @rpath/libTree.so (compatibility version 0.0.0, current version 0.0.0) @rpath/Python (compatibility version 2.7.0, current version 2.7.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)

shows that there is a problem in the linking, since again Python is not where all the other ROOT libraries are.

I have tried to disable using rpath (by the way using --disable-rpath does not work on a mac, since it is conveniently forced to be true for all macs, so I had to manually remove that from configure), but this also has no effect and the issue remains.

I assume that this is not the most common use case – using ROOT from python seems more common than the other way round – but maybe someone has an idea of what could be going wrong here. Fixing this would allow me to use python in our C++/ROOT framework and that could really speed development for me.

Thanks,
Anna

what give autoload? Example:$ root -l -b root [0] TPython::Exec("print \'hello\'") hello (Bool_t) true root [1]
-Dom

Hi Dom,

this gives exactly the same issue, I believe:

root [0] TPython::Exec("print \'hello\'") dlopen error: dlopen(/Users/anelles/Software/root/lib/libPyROOT.so, 9): Library not loaded: @rpath/Python Referenced from: /Users/anelles/Software/root/lib/libPyROOT.so Reason: no suitable image found. Did find: /Users/anelles/Software/root/lib/Python: not a file Load Error: Failed to load Dynamic link library /Users/anelles/Software/root/lib/libPyROOT.so Error in <TCint::AutoLoadCallback>: failure loading library libPyROOT.so for class TPython Error: Function Exec("print \'hello\'") is not defined in current scope (tmpfile):1: *** Interpreter error recovered *** root [1]

Anna

How is Enthought Python install? Is Framework? (I have MacPorts Python; is Framework and all work okay.)

Or is question, what result:$ python -c 'import sys; sys.stdout.write(sys.prefix)'
-Dom

Hi,

Have you build ROOT yourself? You cannot transparently switch from a ROOT built against “regular” MacOS X python to running with another Python install. So rebuilding ROOT, passing your Python in through configuration flags, might do.

Cheers, Axel.

Hi,

thanks for the ideas and sorry for the long latency, been a little busy in the past week.

Dominique, I installed Enthought by downloading from their site. Your command gives me:

python -c 'import sys; sys.stdout.write(sys.prefix)'
/Users/anelles/Library/Enthought/Canopy_64bit/User

This is indeed where my Python installation sits.

And Axel: I build ROOT from source and pointed it to the correct python as input already. When installing, it had trouble finding Python.h out of the box. After fixing that “import ROOT” works, but apparently not using Python from ROOT.
That is why is suspect that something does not work properly in the coordination of Enthought and ROOT, but I cannot figure out what goes wrong. To me, it still seems that the usage of @rpath is wrong in this context.

Thanks,
Anna

oui, is look good, but is not standard. Now question: is the Enthought path in LD_LIBRARY_PATH (or DYLD_LIBRARY_PATH)? All not standard path need pointing to.

-Dom

Try running otool -l lib/libPyROOT.so This should show a couple of entries where the cmd is LC_RPATH. If the library directory of your Python installation (the directory containing the file Python) is not amongst the corresponding paths try adding it with install_name_tool -add_rpath /Users/anelles/Library/Enthought/Canopy_64bit/User/lib (or whatever the correct path is).

Thanks again for the help.

I don’t know how it happened, but the Python was indeed missing from the DYLD path. It must have happened when trying to fix another problem that came up before with our experiment software.
Should have checked that myself #-o

@suhl: Thanks for some more advice. This does not really points you to the actual problem, because it still says @rpath/Python in the linking. This works now with the DYLD_PATH set, but it does not look any different than before when it was not set. Unless there is a way to make it spell out what @rpath is in that case.

Anna

PS: Maybe some of the ROOT guys still want to fix that --disable-rpath during configuration does not do anything for mac anymore, since it always defaults to true on a mac. After all, it was not needed, but it still is confusing.