# Cannot access file in python "unsafe use of relative rpath"

**URL:** <https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565>\
**Category:** ROOT\
**Created:** [October 13, 2017, 7:32am UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565 "2017-10-13T07:32:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [October 13, 2017, 7:32am UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/1 "2017-10-13T07:32:32Z")

</div>

On my Mac, in a ROOT session, I can do:

```auto
$ root
   -----------------------------------------------------------------
  | Welcome to ROOT 6.11/03 http://root.cern.ch |
  | (c) 1995-2017, The ROOT Team |
  | Built for macosx64 |
  | From heads/master@v6-11-02-3-g9bb8349ee6, Oct 10 2017, 13:40:35 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   -----------------------------------------------------------------

root [0] TFile * f = TFile::Open("root://eoslhcb.cern.ch//eos/lhcb/user/m/mwilkins/bfractions_fromGanga/data/Down16/548.100/DVnTuples.root")
(TFile *) 0x7f80932b47a0
root [1] TTree *t
(TTree *) nullptr
root [2] f->GetObject("Tuple_b2DsKMuX/DecayTree",t)
root [3] t->GetMaximum("B_MM")
(double) 7999.719469

```

However, in python:

```auto
$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile
>>> f = TFile.Open("root://eoslhcb.cern.ch//eos/lhcb/user/m/mwilkins/bfractions_fromGanga/data/Down16/548.100/DVnTuples.root")
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdUtils.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdUtils.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary
Error in <TInterpreter::TCling::AutoLoad>: failure loading library libNetxNG.so for TNetXNGSystem
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdUtils.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdUtils.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdUtils.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdUtils.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary
Error in <TInterpreter::TCling::AutoLoad>: failure loading library libNetxNG.so for TNetXNGFile
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdUtils.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdUtils.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary

```

For some reason, it doesn’t like the relative path use in the .so file. Seems the natural fix is not to use a relative path, but I’m nervous about mucking around in the .so file myself. Help?

---

<div class="post-metadata">

**Author:** ![Graipher](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/graipher/32/11624_2.png) [@Graipher](https://root-forum.cern.ch/u/Graipher)\
**Post date:** [October 13, 2017, 3:13pm UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/2 "2017-10-13T15:13:14Z")

</div>

The command works for me on Ubuntu 17.04 / ROOT 6.10/06 / python 2.7.13.  
So it’s probably a Mac specific issue?

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [October 14, 2017, 6:32am UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/3 "2017-10-14T06:32:09Z")

</div>

I am not sure. Could it be an issue with the configuration of the machine? Is this the only thing which cannot be done in PyROOT or other things are broken? We might get more insights…

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![wlav](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/f07891/32.png) [@wlav](https://root-forum.cern.ch/u/wlav)\
**Post date:** [October 14, 2017, 8:03am UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/4 "2017-10-14T08:03:18Z")

</div>

Is that stock python? Apple has been trying to “protect” certain binaries it considers important for the OS, python among them (several shell utilities are written in python, for example). If yes, I’d recommend installing python from one of the Mac distros (MacPorts, Homebrew, etc.), which don’t suffer from the same (and also are kept much better up to date).

(I also remember that there were fixes for this rpath business; must still be around somewhere on this forum if the history was imported.)

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [October 14, 2017, 9:33am UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/5 "2017-10-14T09:33:06Z")

</div>

Even `cp /usr/bin/python ~/bin/` and then calling that might solve it, because it avoids SIP.

---

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [October 15, 2017, 4:06pm UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/6 "2017-10-15T16:06:41Z")

</div>

I don’t know whether this is the _only_ broken thing, but the commands work fine with files stored locally.

```auto
$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile
>>> f = TFile.Open('sweighting/weighted/prepped_MC_weighted_ntuple.root')
>>> from ROOT import TTree
>>> t = TTree()
>>> .ls
TFile** sweighting/weighted/prepped_MC_weighted_ntuple.root	
 TFile* sweighting/weighted/prepped_MC_weighted_ntuple.root	
  KEY: TTree	B2DsKMuNu;1	B2DsKMuNu
>>> f.GetObject("B2DsKMuNu",t)
>>> t.Draw("D_M")
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1

```

@wlav I believe this is stock python. When I try to install it with Homebrew:

```auto
$ brew install python
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
ice

Warning: python 2.7.14 is already installed

```

@Axel could you provide some more details?

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [October 15, 2017, 10:27pm UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/8 "2017-10-15T22:27:34Z")

</div>

At least in some earlier version of the Mac protection system one could `mkdir ~/bin; cp /usr/bin/python ~/bin/; ~/bin/python` and then `from ROOT import...` as always. Does that help?

---

<div class="post-metadata">

**Author:** ![wlav](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/f07891/32.png) [@wlav](https://root-forum.cern.ch/u/wlav)\
**Post date:** [October 15, 2017, 10:33pm UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/9 "2017-10-15T22:33:51Z")

</div>

@mwilkins: using a local file does not load [libNetxNG.so](http://libNetxNG.so), so there is no reason to expect problems with it there. Also, all other .so’s needed for local open (libIO & friends) are directly linked with libPyROOT and not loaded on-demand afterwards.

---

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [October 16, 2017, 6:46am UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/10 "2017-10-16T06:46:35Z")

</div>

@Axel the behavior is the same in this case.

@wlav I did not expect problems. I only tried another command because of @Danilo’s question. When following @Axel’s suggestion though, I noticed

```auto
$ cp /usr/bin/py
pydoc python python2.7 pythonw
pydoc2.7 python-config python2.7-config pythonw2.7

```

Perhaps this is useful since you asked what version of python I had installed?

Per @Danilo’s question, it’s probably not relevant, but I did run into trouble with iPython not picking up my python path when I installed it. Otherwise, I haven’t yet noticed anything else weird about my python installation.

---

<div class="post-metadata">

**Author:** ![wlav](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/f07891/32.png) [@wlav](https://root-forum.cern.ch/u/wlav)\
**Post date:** [October 16, 2017, 4:08pm UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/11 "2017-10-16T16:08:10Z")

</div>

It’s not so much the version, but a matter of system python v.s. non-system python. Where does your homebrew python live? (I’m only familiar with MacPorts.) Can you make sure it and its libraries are first in PATH and LD\_LIBRARY\_PATH respectively? (There probably is a setup script for it that needs to be sourced. There is for MacPorts anyway.)

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [October 16, 2017, 4:55pm UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/12 "2017-10-16T16:55:23Z")

</div>

> [@mwilkins](#):
>
> ```auto
> Python 2.7.10 (default, Jul 15 2017, 17:16:57) 
> [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
> 
> ```

On my mac this is the stock python. The following command will tell you where the python that is being executed lives:

```bash
which python
which python2

```

I believe that by default the system python comes first in the path and may be the reason that the homebrew version is not being evoked. This will list the search paths for binaries:

```bash
printenv PATH

```

This will let you locate all the files named python on the system, one will be the system python and one will be homebrew:

```bash
locate */python

```

This is typically much slower, but may be more exact:

```bash
find / -type f -name "python" 2>/dev/null

```

---

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [October 16, 2017, 5:11pm UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/13 "2017-10-16T17:11:43Z")

</div>

@ksmith @wlav  
I am not sure what the next step should be, but here is the information you requested:

```auto
$ which python
/usr/bin/python
$ which python2
/usr/local/bin/python2
$ printenv PATH
/usr/local/opt/ipython@5/bin:/Applications/root_build/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin  
$ locate */python
/Applications/Atom.app/Contents/Resources/app/apm/bin/python-interceptor.sh
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/bin/python-config
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2-config
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
/Users/michael/bin/python
/usr/bin/python
/usr/bin/python-config
/usr/bin/python2.7
/usr/bin/python2.7-config
/usr/bin/pythonw
/usr/bin/pythonw2.7
/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/python-config
/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/python2
/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/python2-config
/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/pythonw
/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/pythonw2
/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
/usr/local/Cellar/python/2.7.14/bin/python2
/usr/local/Cellar/python/2.7.14/bin/python2-config
/usr/local/Cellar/python/2.7.14/bin/python2.7
/usr/local/Cellar/python/2.7.14/bin/python2.7-config
/usr/local/Cellar/python/2.7.14/bin/pythonw2
/usr/local/Cellar/python/2.7.14/bin/pythonw2.7
/usr/local/Cellar/python/2.7.14/libexec/bin/python
/usr/local/Cellar/python/2.7.14/libexec/bin/python-config
/usr/local/Cellar/python/2.7.14/libexec/bin/pythonw
/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/bin/python3
/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/bin/python3-config
/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/bin/python3.6
/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/bin/python3.6-config
/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/bin/python3.6m
/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/bin/python3.6m-config
/usr/local/Cellar/python3/3.6.3/bin/python3
/usr/local/Cellar/python3/3.6.3/bin/python3-config
/usr/local/Cellar/python3/3.6.3/bin/python3.6
/usr/local/Cellar/python3/3.6.3/bin/python3.6-config
/usr/local/Cellar/python3/3.6.3/bin/python3.6m
/usr/local/Cellar/python3/3.6.3/bin/python3.6m-config
/usr/local/bin/python2
/usr/local/bin/python2-config
/usr/local/bin/python2.7
/usr/local/bin/python2.7-config
/usr/local/bin/python3
/usr/local/bin/python3-config
/usr/local/bin/python3.6
/usr/local/bin/python3.6-config
/usr/local/bin/python3.6m
/usr/local/bin/python3.6m-config
/usr/local/bin/pythonw2
/usr/local/bin/pythonw2.7

```

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [October 16, 2017, 6:58pm UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/14 "2017-10-16T18:58:46Z")

</div>

Try repeating the steps that created the issue, but use the command `python2` instead of `python`. It looks as though this is the version installed by homebrew.

---

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [October 17, 2017, 7:02am UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/15 "2017-10-17T07:02:18Z")

</div>

Alas, no, that’s worse:

```auto
$ python2
Python 2.7.14 (default, Sep 25 2017, 09:54:19) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

```

I tried a few times to uninstall (via both brew uninstall and by just trying to remove directories) and reinstall (via homebrew) python but no luck. In case you’re interested:

```auto
$ python2
Python 2.7.14 (default, Sep 25 2017, 09:54:19) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
$ python2
Python 2.7.14 (default, Sep 25 2017, 09:54:19) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
$ python2
Python 2.7.14 (default, Sep 25 2017, 09:54:19) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
$ brew uninstall python
Error: Refusing to uninstall /usr/local/Cellar/python/2.7.14
because it is required by ipython@5 5.5.0_1, which is currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies python
$ brew uninstall ipython
Error: No such keg: /usr/local/Cellar/ipython
$ pip uninstall ipython
Cannot uninstall requirement ipython, not installed
$ brew uninstall python2
Error: Refusing to uninstall /usr/local/Cellar/python/2.7.14
because it is required by ipython@5 5.5.0_1, which is currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies python2
$ brew uninstall --ignore-dependencies python2
Uninstalling /usr/local/Cellar/python/2.7.14... (3,555 files, 49MB)
$ brew install python
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
baresip ffmpeg mpv rpm
bento4 folly nsq simgrid
cargo-completion fzf passenger xmrig
citus hugo pony-stable
cookiecutter jenkins primesieve
derby libextractor qcli

==> Downloading https://homebrew.bintray.com/bottles/python-2.7.14.high_sierra.b
Already downloaded: /Users/michael/Library/Caches/Homebrew/python-2.7.14.high_sierra.bottle.tar.gz
==> Pouring python-2.7.14.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/python/2.7.14/bin/python2 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python/2.7.14/bin/python2 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python/2.7.14/bin/python2 -s setup.py --no-user-cfg instal
==> Caveats
This formula installs a python2 executable to /usr/local/bin.
If you wish to have this formula's python executable in your PATH then add
the following to ~/.bash_profile:
  export PATH="/usr/local/opt/python/libexec/bin:$PATH"

Pip and setuptools have been installed. To update them
  pip2 install --upgrade pip setuptools

You can install Python packages with
  pip2 install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python.html
==> Summary
🍺 /usr/local/Cellar/python/2.7.14: 3,517 files, 48.4MB
$ pip2 install --upgrade pip setuptools
Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages
Collecting setuptools
  Downloading setuptools-36.6.0-py2.py3-none-any.whl (481kB)
    100% |████████████████████████████████| 481kB 2.0MB/s 
Installing collected packages: setuptools
  Found existing installation: setuptools 36.5.0
    Uninstalling setuptools-36.5.0:
      Successfully uninstalled setuptools-36.5.0
Successfully installed setuptools-36.6.0
$ mm .bash_profile
[1] 59358
$ python2
Python 2.7.14 (default, Sep 25 2017, 09:54:19) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile
Fatal Python error: PyThreadState_Get: no current thread
[1]+ Done emacs $var
Abort trap: 6
$ which python
/usr/bin/python
$ which python2
/usr/local/bin/python2
$ which python3
/usr/local/bin/python3
$ rm -r /usr/bin/python
python python2.7 pythonw           
python-config python2.7-config pythonw2.7        
$ rm -r /usr/bin/python*
override rwxr-xr-x root/wheel restricted,compressed for /usr/bin/python? n
override rwxr-xr-x root/wheel restricted,compressed for /usr/bin/python-config? n
rm: /usr/bin/python2.7: Operation not permitted
rm: /usr/bin/python2.7-config: Operation not permitted
override rwxr-xr-x root/wheel restricted,compressed for /usr/bin/pythonw? rm -r /usr/bin/python
rm: /usr/bin/pythonw2.7: Operation not permitted
$ rm -r /usr/bin/python*
override rwxr-xr-x root/wheel restricted,compressed for /usr/bin/python? yes
rm: /usr/bin/python: Operation not permitted
override rwxr-xr-x root/wheel restricted,compressed for /usr/bin/python-config? no
rm: /usr/bin/python2.7: Operation not permitted
rm: /usr/bin/python2.7-config: Operation not permitted
override rwxr-xr-x root/wheel restricted,compressed for /usr/bin/pythonw? no
rm: /usr/bin/pythonw2.7: Operation not permitted
$ 
$ 
$ 
$ rm -r /usr/local/bin/py
pydoc2 python2 python3-config pythonw2
pydoc2.7 python2-config python3.6 pythonw2.7
pydoc3 python2.7 python3.6-config pyvenv
pydoc3.6 python2.7-config python3.6m pyvenv-3.6
pygmentize python3 python3.6m-config  
$ rm -r /usr/local/bin/python2
$ rm -r /usr/local/bin/python3
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
  /Applications/root_build/bin/root-config
$ brew prune
$ brew install python
Warning: python 2.7.14 is already installed
$ python2
-bash: /usr/local/bin/python2: No such file or directory
$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile
>>> f = TFile.Open("root://eoslhcb.cern.ch//eos/lhcb/user/m/mwilkins/bfractions_fromGanga/data/Down16/548.100/DVnTuples.root")
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdUtils.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdUtils.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary
Error in <TInterpreter::TCling::AutoLoad>: failure loading library libNetxNG.so for TNetXNGSystem
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdUtils.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdUtils.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdUtils.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdUtils.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary
Error in <TInterpreter::TCling::AutoLoad>: failure loading library libNetxNG.so for TNetXNGFile
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdUtils.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdUtils.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary
>>> ^D
$ brew uninstall python
Error: Refusing to uninstall /usr/local/Cellar/python/2.7.14
because it is required by ipython@5 5.5.0_1, which is currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies python
$ brew uninstall --ignore-dependenies python
Error: Refusing to uninstall /usr/local/Cellar/python/2.7.14
because it is required by ipython@5 5.5.0_1, which is currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies python
$ brew uninstall --ignore-dependencies python
Uninstalling /usr/local/Cellar/python/2.7.14... (3,564 files, 49.2MB)
$ brew uninstall --ignore-dependencies python
Error: No such keg: /usr/local/Cellar/python
$ which python
/usr/bin/python
$ rm -r /usr/bin/python
override rwxr-xr-x root/wheel restricted,compressed for /usr/bin/python? yes
rm: /usr/bin/python: Operation not permitted
$ rm -r /usr/bin/python
override rwxr-xr-x root/wheel restricted,compressed for /usr/bin/python? y
rm: /usr/bin/python: Operation not permitted
$ which python
/usr/bin/python
$ brew install python2
==> Downloading https://homebrew.bintray.com/bottles/python-2.7.14.high_sierra.b
Already downloaded: /Users/michael/Library/Caches/Homebrew/python-2.7.14.high_sierra.bottle.tar.gz
==> Pouring python-2.7.14.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/python/2.7.14/bin/python2 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python/2.7.14/bin/python2 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python/2.7.14/bin/python2 -s setup.py --no-user-cfg instal
==> Caveats
This formula installs a python2 executable to /usr/local/bin.
If you wish to have this formula's python executable in your PATH then add
the following to ~/.bash_profile:
  export PATH="/usr/local/opt/python/libexec/bin:$PATH"

Pip and setuptools have been installed. To update them
  pip2 install --upgrade pip setuptools

You can install Python packages with
  pip2 install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python.html
==> Summary
🍺 /usr/local/Cellar/python/2.7.14: 3,517 files, 48.4MB
$ pip2 install --upgrade pip setuptools
Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages
Collecting setuptools
  Using cached setuptools-36.6.0-py2.py3-none-any.whl
Installing collected packages: setuptools
  Found existing installation: setuptools 36.5.0
    Uninstalling setuptools-36.5.0:
      Successfully uninstalled setuptools-36.5.0
Successfully installed setuptools-36.6.0
$ python2
Python 2.7.14 (default, Sep 25 2017, 09:54:19) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
$ 

```

---

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [October 17, 2017, 11:33am UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/16 "2017-10-17T11:33:16Z")

</div>

Okay so I found on [this thread](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-osx-10-9-mavericks/17287) that python quitting is due to conflicting python versions. The same thread recommends sticking with the system build though.

I think this is a legitimate bug related to Apple’s introduction of [System Integrity Protection](https://support.apple.com/en-us/HT204899). I was able to fix it using install\_name\_tool. Unfortunately, there were several such links so it needed to be done multiple times; there’s a suggestion [here](https://stackoverflow.com/questions/31343299/mysql-improperly-configured-reason-unsafe-use-of-relative-path) for doing it automatically, but I just did it manually:

```bash
$ install_name_tool -change libXrdUtils.2.dylib /Applications/root_build/lib/libXrdUtils.2.dylib /Applications/root_build/lib/libNetxNG.so
$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile
>>> f = TFile.Open("root://eoslhcb.cern.ch//eos/lhcb/user/m/mwilkins/bfractions_fromGanga/data/Down16/548.100/DVnTuples.root")
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdCl.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdCl.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary
Error in <TInterpreter::TCling::AutoLoad>: failure loading library libNetxNG.so for TNetXNGSystem
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdCl.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdCl.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdCl.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdCl.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary
Error in <TInterpreter::TCling::AutoLoad>: failure loading library libNetxNG.so for TNetXNGFile
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdCl.2.dylib
  Referenced from: /Applications/root_build/lib/libNetxNG.so
  Reason: unsafe use of relative rpath libXrdCl.2.dylib in /Applications/root_build/lib/libNetxNG.so with restricted binary
>>> ^D
$ install_name_tool -change libXrdCl.2.dylib /Applications/root_build/lib/libXrdCl.2.dylib /Applications/root_build/lib/libNetxNG.so
$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile ; f = TFile.Open("root://eoslhcb.cern.ch//eos/lhcb/user/m/mwilkins/bfractions_fromGanga/data/Down16/548.100/DVnTuples.root")
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdXml.2.dylib
  Referenced from: /Applications/root_build/lib/libXrdCl.2.dylib
  Reason: unsafe use of relative rpath libXrdXml.2.dylib in /Applications/root_build/lib/libXrdCl.2.dylib with restricted binary
Error in <TInterpreter::TCling::AutoLoad>: failure loading library libNetxNG.so for TNetXNGSystem
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdXml.2.dylib
  Referenced from: /Applications/root_build/lib/libXrdCl.2.dylib
  Reason: unsafe use of relative rpath libXrdXml.2.dylib in /Applications/root_build/lib/libXrdCl.2.dylib with restricted binary
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdXml.2.dylib
  Referenced from: /Applications/root_build/lib/libXrdCl.2.dylib
  Reason: unsafe use of relative rpath libXrdXml.2.dylib in /Applications/root_build/lib/libXrdCl.2.dylib with restricted binary
Error in <TInterpreter::TCling::AutoLoad>: failure loading library libNetxNG.so for TNetXNGFile
cling::DynamicLibraryManager::loadLibrary(): dlopen(/Applications/root_build/lib/libNetxNG.so, 9): Library not loaded: libXrdXml.2.dylib
  Referenced from: /Applications/root_build/lib/libXrdCl.2.dylib
  Reason: unsafe use of relative rpath libXrdXml.2.dylib in /Applications/root_build/lib/libXrdCl.2.dylib with restricted binary
>>> ^D
$ install_name_tool -change libXrdXml.2.dylib /Applications/root_build/lib/libXrdXml.2.dylib /Applications/root_build/lib/libXrdCl.2.dylib
...

```

etc.

Now I’ve got a new problem:

```python
$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile
>>> f = TFile.Open("root://eoslhcb.cern.ch//eos/lhcb/user/m/mwilkins/bfractions_fromGanga/data/Down16/548.100/DVnTuples.root")
Error in <TNetXNGFile::Open>: [FATAL] Auth failed

```

But it seems unrelated to the original problem in this post, so I will simply start a [new thread](https://root-forum.cern.ch/t/pyroot-cannot-open-file-error-in-tnetxngfile-open-fatal-auth-failed/26593). Thanks much for taking the time to help, everyone.

By the way, there are WAY too many problems trying to get this installation up and running. I almost regret even trying.

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [October 17, 2017, 1:44pm UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/17 "2017-10-17T13:44:27Z")

</div>

> [@mwilkins](#):
>
> ```python
> $ python2
> Python 2.7.14 (default, Sep 25 2017, 09:54:19) 
> [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from ROOT import TFile
> Fatal Python error: PyThreadState_Get: no current thread
> Abort trap: 6
> 
> ```

> [@mwilkins](#):
>
> Okay so I found on this thread that python quitting is due to conflicting python versions. The same thread recommends sticking with the system build though.

This is the same error message I get from the system python, therefore I assume you build ROOT against the system python and not homebrew. You can check which python you built against with this command:

```bash
grep "/python$" root-build-dir/CMakeCache.txt

```

I am avoiding using the system python and building ROOT against the version provided from macports (the same can be done with homebrew). macports provides a simple method to set there version as the default in the path and I suspect something like that exists for homebrew as well. After that the build of ROOT will use the non system python by default. Alternatively, you can force CMake to use a specific version of python with the following:

```bash
cmake root-source -DPYTHON_EXECUTABLE=/usr/local/bin/python

```

> [@How to properly install PyROOT for Python 3?](https://root-forum.cern.ch/t/how-to-properly-install-pyroot-for-python-3/26367/3):
>
> You can use -DPYTHON\_EXECUTABLE=/path/to/desired/python without aliasing anything.

---

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [October 17, 2017, 2:07pm UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/18 "2017-10-17T14:07:50Z")

</div>

Thanks for the guidance. I don’t see any reason to install python3 or anything other than the system version at this point though. (I need to stick with python2.7 for LHCb compatibility reasons.)

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [October 17, 2017, 2:11pm UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/19 "2017-10-17T14:11:23Z")

</div>

Sorry I didn’t meant to confuse the issue with python3. I was just indicating how to avoid the macOS system version of python 2.7 that has SIP.

---

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [October 19, 2017, 4:21am UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/20 "2017-10-19T04:21:19Z")

</div>

So it turns out that this is actually just a symptom of the underlying issue with SIP—Seems the default version of python has system integrity protection that interferes with the ROOT build operating as designed.

True solution here:

> [@PyROOT cannot open file: "Error in \<TNetXNGFile::Open\>: \[FATAL\] Auth failed"](https://root-forum.cern.ch/t/pyroot-cannot-open-file-error-in-tnetxngfile-open-fatal-auth-failed/26593/20):
>
> @ksmith So it looks like you’re right. It’s an issue with SIP that can be worked around using a different, non-system python. However, that one flag alone is not enough. I had to do: cmake -Dall=On -DPYTHON\_EXECUTABLE=/usr/local/bin/python2 -DPYTHON\_INCLUDE\_DIR=/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/Headers -DPYTHON\_LIBRARY=/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib ../root/ pointing it at the Homebrew vers…

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [November 2, 2017, 4:21am UTC](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565/21 "2017-11-02T04:21:32Z")

</div>

Closed on November 2, 2017, 4:21am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Next page](https://root-forum.cern.ch/t/cannot-access-file-in-python-unsafe-use-of-relative-rpath/26565.md?page=2)
