# Trouble importing pyROOT on Mac OS X 10.11.1

**URL:** <https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000>\
**Category:** ROOT\
**Created:** [April 20, 2016, 3:11am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000 "2016-04-20T03:11:35Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![edwrdg13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/4491bb/32.png) [@edwrdg13](https://root-forum.cern.ch/u/edwrdg13)\
**Post date:** [April 20, 2016, 3:11am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/1 "2016-04-20T03:11:35Z")

</div>

Hi,

My ROOT installation seems to be working fine, but when I try to import pyROOT, I get this error: [code]Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 12:54:16)  
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin  
Type “help”, “copyright”, “credits” or “license” for more information.

> > > import ROOT  
> > > Fatal Python error: PyThreadState\_Get: no current thread  
> > > Abort trap: 6

[/code]. I believe this has to do with ROOT being built against one python but being imported against another, but I’m not sure how to resolve this.

I’ve followed the thread here: [url][Trouble importing pyROOT on OSX 10.9 Mavericks](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-osx-10-9-mavericks/17287/1)  
and I have: `otool -L /root/lib/libPyROOT.so
/root/lib/libPyROOT.so:
	@rpath/libPyROOT.so (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libTree.so (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
	@rpath/libRIO.so (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libCore.so (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)`.

Based on the thread, I tried this: `install_name_tool -change libpython2.7.dylib /Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib libPyROOT.so` but the error still appears.

I’ve tried to debug this but without success, and I would really appreciate if anyone would be able to help out with this.

Thanks!

---

<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:** [April 20, 2016, 3:58am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/2 "2016-04-20T03:58:15Z")

</div>

Hi,

the Python module is called ROOT. So you should type

```auto
Import ROOT
```

D

---

<div class="post-metadata">

**Author:** ![edwrdg13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/4491bb/32.png) [@edwrdg13](https://root-forum.cern.ch/u/edwrdg13)\
**Post date:** [April 20, 2016, 4:43am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/3 "2016-04-20T04:43:18Z")

</div>

Hi,

Thanks for the reply!

I recieve the following error when I type `import ROOT`:

[code]Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 12:54:16)  
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin  
Type “help”, “copyright”, “credits” or “license” for more information.

> > > import ROOT  
> > > Fatal Python error: PyThreadState\_Get: no current thread  
> > > Abort trap: 6  
> > > dhcp-18-189-16-11:lib edward$

[/code]

Best,

Edward

---

<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:** [April 20, 2016, 5:09am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/4 "2016-04-20T05:09:59Z")

</div>

Hi Edward,

might I ask you not to change your previous posts? It might result in something misleading for the future readers 😉  
Do you have several distributions of Python on your system?

D

---

<div class="post-metadata">

**Author:** ![edwrdg13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/4491bb/32.png) [@edwrdg13](https://root-forum.cern.ch/u/edwrdg13)\
**Post date:** [April 20, 2016, 5:40am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/5 "2016-04-20T05:40:07Z")

</div>

Hi,

Sorry about that. The preinstalled python distribution is located at `/usr/bin/python`, but the python distribution that I’m using is located at: `/Library/Frameworks/Python.framework/Versions/2.7/bin/python` I’ve attempted to direct pyROOT to the second distribution by modifying my bash file: [code]#ROOT  
export ROOTSYS=/root  
export PATH=$ROOTSYS/bin:$PATH  
export LD\_LIBRARY\_PATH=$ROOTSYS/lib:$LD\_LIBRARY\_PATH

#PYROOT  
export PYTHONDIR=/Library/Frameworks/Python.framework/Versions/2.7/bin/python  
export PATH=$ROOTSYS/bin:$PYTHONDIR/bin:$PATH  
export LD\_LIBRARY\_PATH=$ROOTSYS/lib:$PYTHONDIR/lib:$LD\_LIBRARY\_PATH  
export PYTHONPATH=$ROOTSYS/lib:$PYTHONPATH

# Setting PATH for Python 2.7

# The orginal version is saved in .bash\_profile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"  
export PATH[/code]

Best,

Edward

---

<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:** [April 20, 2016, 7:17am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/6 "2016-04-20T07:17:46Z")

</div>

I think that there might be a conflict due to the presence of two installations at _config time_.  
Is it an option to try and remove the non-Apple python and proceed with a new ROOT build?

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:** [April 20, 2016, 8:25am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/7 "2016-04-20T08:25:34Z")

</div>

Edward,

> [@edwrdg13](#):
>
> The preinstalled python distribution is located at `/usr/bin/python`, but the python distribution that I’m using is located at: `/Library/Frameworks/Python.framework/Versions/2.7/bin/python`

The other way around should be preferred.

[quote=“edwrdg13”]I’ve attempted to direct pyROOT to the second distribution by modifying my bash file:[/quote]PyROOT is not affected by any of those (not with the setup you show above anyway).

You need to make sure that the python version that you used to build PyROOT comes first in PATH. However, what you do here:[quote=“edwrdg13”]`export PYTHONDIR=/Library/Frameworks/Python.framework/Versions/2.7/bin/python`[/quote]is setting PYTHONDIR to the python binary (which is not a directory). Either way, the system python is not affected by envars, and if it were, you’d want to set PYTHONHOME.

From there:[quote=“edwrdg13”]`export PATH=$ROOTSYS/bin:$PYTHONDIR/bin:$PATH`[/quote]does not do you any good, as $PYTHONDIR/bin (or lib) does of course not exist.

What you have to do, is check what `which python` gives you, and if that is not the system one (as you seem to want for this setup), then add ‘/Library/Frameworks/Python.framework/Versions/2.7/bin’ to PATH (and ‘/Library/Frameworks/Python.framework/Versions/2.7/lib’ to (DY)LD\_LIBRARY\_PATH.

HTH,  
Wim

---

<div class="post-metadata">

**Author:** ![edwrdg13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/4491bb/32.png) [@edwrdg13](https://root-forum.cern.ch/u/edwrdg13)\
**Post date:** [April 20, 2016, 5:42pm UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/8 "2016-04-20T17:42:19Z")

</div>

Hi,

typing ‘which python’ returns: `dhcp-18-189-16-11:~ edward$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python`

> [@](#):
>
> What you have to do, is check what `which python` gives you, and if that is not the system one (as you seem to want for this setup), then add ‘/Library/Frameworks/Python.framework/Versions/2.7/bin’ to PATH (and ‘/Library/Frameworks/Python.framework/Versions/2.7/lib’ to (DY)LD\_LIBRARY\_PATH.

I’ve attempted to do this. My bash file is now:

[code]# Setting PATH for Python 2.7

# The orginal version is saved in .bash\_profile.pysave

PATH=“/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}”  
export PATH  
export LD\_LIBRARY\_PATH=/Library/Frameworks/Python.framework/Versions/2.7/lib

#ROOT  
export ROOTSYS=/root  
export PATH=$ROOTSYS/bin:$PATH  
export LD\_LIBRARY\_PATH=$ROOTSYS/lib:$LD\_LIBRARY\_PATH

#PYROOT  
export PYTHONDIR=/Library/Frameworks/Python.framework/Versions/2.7/bin/  
export PATH=$ROOTSYS/bin:$PYTHONDIR/bin:$PATH  
export LD\_LIBRARY\_PATH=$ROOTSYS/lib:$PYTHONDIR/lib:$LD\_LIBRARY\_PATH  
export PYTHONPATH=$ROOTSYS/lib:$PYTHONPATH  
[/code]

Trying to import ROOT still returns the same error: `>>> import ROOT
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6`

Is there anything else that you suggest I do?

Thanks,

Edward

---

<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:** [April 20, 2016, 6:05pm UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/9 "2016-04-20T18:05:04Z")

</div>

Edward,

what does your current ‘otool -L $ROOTSYS/lib/libPyROOT.so’ give you? (Above that points to the system python, but then above you also state that you ran install\_name\_tool.)

What is the version of the python binary that you are running now? (Above you print it, the last you cut if off. I have 2.7.10 under /usr/bin, and 2.7.3 under /Library; I have a pending update so maybe that brings me to 2.7.11 that you have, or something is still not proper.)

One way or another the interpreter loaded by the binary is still different from the one loaded by [libPyROOT.so](http://libPyROOT.so). Since it lives in a shared library in both cases, it has to be the same for things to work. So, compare:`otool -L `which python``with:`otool -L $ROOTSYS/lib/libPyROOT.so` and see whether there are still any differences left.

Cheers,  
Wim

---

<div class="post-metadata">

**Author:** ![edwrdg13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/4491bb/32.png) [@edwrdg13](https://root-forum.cern.ch/u/edwrdg13)\
**Post date:** [April 20, 2016, 6:11pm UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/10 "2016-04-20T18:11:09Z")

</div>

Hi Wim,

Those return:

`edward$ otool -L `which python`
/Library/Frameworks/Python.framework/Versions/2.7/bin/python:
	/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)`

and `edward$ otool -L $ROOTSYS/lib/libPyROOT.so
/root/lib/libPyROOT.so:
	@rpath/libPyROOT.so (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libTree.so (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
	@rpath/libRIO.so (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libCore.so (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)`

Do you know the best way of making those the same? Would it be worth uninstalling python and reinstalling ROOT as dpiparo suggested?

Best,

Edward

---

<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:** [April 20, 2016, 6:24pm UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/11 "2016-04-20T18:24:07Z")

</div>

Edward,

yes, I’d reconfigure (with current PATH; I’m not sure about cmake, but the configure script used to pick python up from there) and rebuild. (install\_name\_tool might work and the two should be binary compatible, but those are famous last words.)

Cheers,  
Wim

---

<div class="post-metadata">

**Author:** ![edwrdg13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/4491bb/32.png) [@edwrdg13](https://root-forum.cern.ch/u/edwrdg13)\
**Post date:** [April 21, 2016, 12:30am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/12 "2016-04-21T00:30:19Z")

</div>

Hi,

To reconfigure would I download the source and compile with `./configure --with-python-incdir=... --with-python-libdir=...`, or is there a better way?

Best,

Edward

---

<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:** [April 21, 2016, 1:50am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/13 "2016-04-21T01:50:00Z")

</div>

Edward,

if the right python is first in PATH, the configure script will pick it up with no further need of incdir/libdir. I don’t know about cmake (never used it).

Cheers,  
Wim

---

<div class="post-metadata">

**Author:** ![edwrdg13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/4491bb/32.png) [@edwrdg13](https://root-forum.cern.ch/u/edwrdg13)\
**Post date:** [April 21, 2016, 4:55am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/14 "2016-04-21T04:55:43Z")

</div>

Hi,

Thanks for the advice. I’ve recompiled ROOT from the source, and it seems to be working fine. When trying to import ROOT, now, I receive this error: [code]\>\>\> import ROOT  
Traceback (most recent call last):  
File “”, line 1, in   
ImportError: No module named ROOT

> > > [/code]

Do you know how to resolve this?

Cheers,

Edward

---

<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:** [April 21, 2016, 6:57am UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/15 "2016-04-21T06:57:31Z")

</div>

Edward,

assuming that it build (check $ROOTSYS/lib for [ROOT.py](http://ROOT.py)), make sure that $ROOTSYS/lib is in the $PYTHONPATH envar.

Cheers,  
Wim

---

<div class="post-metadata">

**Author:** ![edwrdg13](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/4491bb/32.png) [@edwrdg13](https://root-forum.cern.ch/u/edwrdg13)\
**Post date:** [April 21, 2016, 5:41pm UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/16 "2016-04-21T17:41:03Z")

</div>

Hi,

I’m not sure if I’m misunderstanding. I modified the bash profile to: [code]#ROOT  
export ROOTSYS=/Applications/root\_v6.04.16  
export PATH=$ROOTSYS/bin:$PATH  
export LD\_LIBRARY\_PATH=$ROOTSYS/lib:$LD\_LIBRARY\_PATH  
export PYTHONPATH=$ROOTSYS/lib

[/code]

However, I’m still receiving the error `Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6`

otool seems to suggest that ROOT is still using the system python distribution:

` otool -L libPyROOT.so
libPyROOT.so:
	@rpath/libPyROOT.so (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libTree.so (compatibility version 0.0.0, current version 0.0.0)
	/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
	@rpath/libRIO.so (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libCore.so (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)`

Is there a way to manually change this? Or is there some other fix?

Best,  
Edward

---

<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:** [April 21, 2016, 8:42pm UTC](https://root-forum.cern.ch/t/trouble-importing-pyroot-on-mac-os-x-10-11-1/21000/17 "2016-04-21T20:42:01Z")

</div>

Edward,

config.log should show which python was picked up. Check that to see what went wrong. There are no paths pointing directly to /System hardwired in configure, so I don’t see how it can pick up the system ones if the python in PATH is the /Library one.

Cheers,  
Wim
