Trouble importing pyROOT on OSX 10.9 Mavericks

Hi everyone!

I’ve followed the thread laid out here:
[root.cern.ch/phpBB3/viewtopic.p … 9ae8a01de1](pyRoot on OS X Maverick
and ROOT appears to work just fine - I’ve tried out the $ROOTSYS/tutorials and all of them appear to be working.

This is my setup:
ROOT 5.34/14 (v5-34-14@v5-34-14, Dec 16 2013, 12:23:58 on macosx64)

However, when trying to run pyroot, i.e. import ROOT in a python session, python dies right away:

Python 2.7.6 |Anaconda 1.9.0 (x86_64)| (default, Jan 10 2014, 11:23:15)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

Trying to debug with lldb (apple decided to get rid of gdb) yields marginally more insight but not enough to know what’s going on:

lldb python
Current executable set to ‘python’ (x86_64).
(lldb) run
Process 68145 launched: ‘/Users/zimmer/anaconda/bin/python’ (x86_64)
Python 2.7.6 |Anaconda 1.9.0 (x86_64)| (default, Jan 10 2014, 11:23:15)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT
Fatal Python error: PyThreadState_Get: no current thread
Process 68145 stopped

  • thread #1: tid = 0x8d92c, 0x00007fff92325866 libsystem_kernel.dylib__pthread_kill + 10, queue = 'com.apple.main-thread, stop reason = signal SIGABRT frame #0: 0x00007fff92325866 libsystem_kernel.dylib__pthread_kill + 10
    libsystem_kernel.dylib`__pthread_kill + 10:
    -> 0x7fff92325866: jae 0x7fff92325870 ; __pthread_kill + 20
    0x7fff92325868: movq %rax, %rdi
    0x7fff9232586b: jmpq 0x7fff92322175 ; cerror_nocancel
    0x7fff92325870: ret
    (lldb)

I’ve tried to debug this without any success so far and would appreciate if anyone would happen to know a fix on how to resolve this. Thanks!

P.s. I get the same results when I try to follow these instructions
alexpearce.me/2013/12/root-on-os-x-mavericks/
and use homebrew to build root.

Hi,

this happens when ROOT is built against one python, then imported in another. Make sure that they’re consistent, by having the custom python you intend to use first up in $PATH (and by pointing --with-python-libdir and --with-python-incdir to your custom python as needed).

(In general, I recommend to stick to the system python on Mac, or use a packager like e.g. MacPorts.)

Cheers,
Wim

Hello,
I had the same problem and I found very useful to fix this problem this post:
groups.google.com/a/continuum.i … NxLsRxLcwJ
In particular I fixed the problem using:

[quote]Everything I have read suggests this is due to conflicting python installations. So following some other threads, I do the following

otool -L /Users/walkloud/install/root/lib/libPyROOT.so

/Users/walkloud/install/root/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 1197.1.1)

@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/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)

libpython2.7.dylib (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)

The second to last line is the culprit - this lib should be pointing to the anaconda python lib, but it is actually catching the /System python lib… So then I use install_name_tool to fix the path of this lib

install_name_tool -change libpython2.7.dylib /Users/walkloud/install/anaconda/lib/libpython2.7.dylib libPyROOT.so
and then the above ROOT import works and I can interact as described via the pyroot docs, at least the minimal testing.

[/quote]

1 Like

I’m having the same problem with pyroot and anaconda. I’ve tried cmake and the old style ./configure; make

Mac OS X El Capitan 10.11.3

root-v6-06-02$ gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 7.0.2 (clang-700.1.81) Target: x86_64-apple-darwin15.3.0 Thread model: posix

root-v6-06-02$ python --version Python 2.7.11 :: Anaconda 2.5.0 (x86_64)

root-v6-06-02$ which python //anaconda/bin/python

[code]root_git$ git branch

  • v6-06-02[/code]

I make a parallel directory to build and issue this cmake command

build succeeds
[100%] Built target hist2workspace

then:

[code]root-v6-06-02$ source bin/thisroot.sh

root-v6-06-02$ python
Python 2.7.11 |Anaconda 2.5.0 (x86_64)| (default, Dec 6 2015, 18:57:58)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org

import ROOT
Fatal Python error: PyThreadState_Get: no current thread

Abort trap: 6
[/code]

then I tried the suggestion here:

[code]root-v6-06-02$ install_name_tool -change libpython2.7.dylib /anaconda/lib/libpython2.7.dylib lib/libPyROOT.so

root-v6-06-02$ python
Python 2.7.11 |Anaconda 2.5.0 (x86_64)| (default, Dec 6 2015, 18:57:58)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org

import ROOT
[/code]

I had the same issue with the ./configure make approach (different directory

root_git$ ./configure --enable-roofit --enable-rpath --enable-mathmore --enable-fftw3 --enable-python --enable-tmva --with-python-incdir=/anaconda/include/python2.7/ --with-python-libdir=/anaconda/lib/

root_git$ make -j4

root_git$ source bin/thisroot.sh 
root_git$ python
Python 2.7.11 |Anaconda 2.5.0 (x86_64)| (default, Dec  6 2015, 18:57:58) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import ROOT
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

root_git$  install_name_tool -change libpython2.7.dylib /anaconda/lib/libpython2.7.dylib lib/libPyROOT.so 
root_git$ python
Python 2.7.11 |Anaconda 2.5.0 (x86_64)| (default, Dec  6 2015, 18:57:58) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import ROOT
>>>