Dyld: Library not loaded in ROOT 6

Hi,
When I use python shell script to run ExRootAnalysis, like:

  os.system('./ExRootLHEFConverter '+'target.lhe'+' '+'target.root')

When I use ROOT 5, it works well. But when I turn to ROOT 6, there is an error, ( of course when I use ROOT 6, I can run the “./ExRootLHEFConverter target.lhe target.root” outside of python)

dyld: Library not loaded: @rpath/libCore.so
  Referenced from: /Users/li/tools/packages/ExRootAnalysis2/ExRootLHEFConverter
  Reason: image not found

I have added the path of lib to .bash_profile

export ROOTSYS=/Users/li/tools/root
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$ROOTSYS/lib
PYTHONPATH="$ROOTSYS/lib:$PYTHONPATH"
export PYTHONPATH

So what can I do to fix this error? And I use mac 10.11 and ROOT 6.06/6 ( while using root 5.34/36, it works well).

Best,
Li

The problem is that Apple is playing very safe here. With 10.11 any executable that comes from /usr/bin removes DYLD_LIBRARY_PATH from the environment. So, if your python comes from /usr/bin you will not see the environment variable DYLD_LIBRARY_PATH

python
>>> import os
>>> os.getenv('DYLD_LIBRARY_PATH')

If this works, then the next hurdle is os.system. This spawns a shell, which happens to reside in /usr/bin, therefore the variable is removed at the time you invoke ./ExRootLHEFConverter.
You can replace os.system by subprocess.call to overcome the problem.

Pere

[quote=“mato”]The problem is that Apple is playing very safe here. With 10.11 any executable that comes from /usr/bin removes DYLD_LIBRARY_PATH from the environment. So, if your python comes from /usr/bin you will not see the environment variable DYLD_LIBRARY_PATH

python
>>> import os
>>> os.getenv('DYLD_LIBRARY_PATH')

If this works, then the next hurdle is os.system. This spawns a shell, which happens to reside in /usr/bin, therefore the variable is removed at the time you invoke ./ExRootLHEFConverter.
You can replace os.system by subprocess.call to overcome the problem.

Pere[/quote]

Hi, Pere

It works! Excellent answer, thanks a lot!

Best,
Li