Lion (Python 2.7) and PyROOT

Mac OS 10.7 now defaults to Python 2.7.1, and gives this error:

[code]$ python
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap: 6[/code]
I can use python2.6 in the short term, and that works, but is this likely to be something I can fix by changing PATHs or recompiling ROOT, or will it require a more complicated fix?



recompilation would be the ticket if you want to use p2.7. On Linux, different versions can sometimes be exchanged if they have no API changes, but that’s simply not an option on Mac.


Thanks! My current status is that root 5.30 doesn’t compile on Lion, but head does. Unfortunately it breaks another tool I’m using, so for the moment I’m using python2.6 and the old version. When I have time and if I figure it out I’ll post recipe here.

I am having similar problems, I would like to use Python 2.7 from MacPorts and ROOT from MacPorts, in such a way that they work together with PyROOT. Is this possible? I emailed the port maintainers about this, and I’ll report here if I make any progress.

Note about ROOT: the MacPorts port compiles if you use the +gcc44 option (haven’t tried +gcc45), but the default compiler LLVM-something does not succeed.


I was able to compile ROOT myself and make pyROOT work with the python 2.7 from MacPorts. I had to do the following:

sudo port install glew +x11 (ref: [url]Problem OpenGL on Mac OS X 10.6 - Fixed )

mkdir ~/Software;cd ~/Software
svn co root
cd root
./configure macosx64 --enable-python --with-python-incdir=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/ --with-python-libdir=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/
Where you may have to substitute in the --with-python-incdir the directory where "Python.h" lives for the python you want to use, and the --with-python-libdir for libpython2.7.dylib.

I ran into some compilation errors, which were fixed by
[code]make distclean-xrootd
make all-xrootd
(ref [url] )
And finally
[code]. bin/
export LD_LIBRARYPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib:$LD_LIBRARYPATH

Those last two should be in one of your bash startup scripts. Now pyROOT works!


I tried your prescription for the python 2.7 version, but still ROOT cannot be imported in python. Seems like the configure and make went smoothly, and I included the paths as one needs to, in my .bashrc file.

Any more hints/experience on how to get pyroot working?

I am trying to get it working on Mac os 10.7 (macbook air)


Can you post the error message that you get when you try to import ROOT from python? It’s hard to diagnose, because among other things, the ROOT configuration/compilation will still continue even if the parameters were incorrect. In the jumble of text that is sprayed onto your terminal, there will be warnings, but the process would continue.

A reasonable test would be to see if you have a file called anywhere on your system. In my case I find a copy in /Users/myusername/Software/root/lib/ (though I also have ROOT.pyc in the same directory). Thus when I import ROOT in python, ROOT.module says it is from that ROOT.pyc file.

Basically there are many things that could have gone wrong, so please check the output of the ROOT configure and (less likely to be useful) compile steps. Also check for, but try to figure out what the error messages are telling you.

Good luck!


thanks for your reply.

I attach the config.log - I cannot find any warnings here, but maybe I am don´t know exactly what to look for (except the obvious warning word!).

I also attach my .bashrc file where I have set the paths and the config.status showing the configure options used.

the message I get when trying to import ROOT is simply:

I first just followed the normal installation instructions from the ROOT pyroot page: … nterpreter

and then when I got the import-error, I removed the whole root directory and tried a new install following the procedure posted here, using Xcode and MacPort. And setting the python paths as suggested.

I found in my /bindings/pyroot folder under my ROOTSYS path

Thanks a lot,

Hi again,

update: I tried the recipe again, and now things are a bit different, although not correct, I get:

I found a similar post here:
[url]TPySelector usage problems

but that fix did not seem to work for me.

I did install with macosx64 option for architecture, maybe that was a mistake? Or maybe it does not have anything to do with the problem?

More suggestions welcome!


so I found a setup that worked! For others which might be facing the same problem, this is what I did, and what I placed in my .bash_profile file

Installed ROOT exactly as described in the entry of this post of Wednesday Sep 14 at 4:25 by jfcaron.

Then in my .bash_profile file I have (when I have ROOT installed in folder /usr/local/root)

It might be that some of the lines are duplications/unnesseary things, but at least things work now, and that is good enough!!


I have no troubles compiling the head version using cmake but when I tried to import pyroot I get the following error:

import ROOT Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/", line 85, in <module> import libPyROOT as _root ImportError: dlopen(/usr/local/lib/, 2): Symbol not found: __ZN10TSSLSocket11ShowMembersER16TMemberInspector Referenced from: /usr/local/lib/ Expected in: flat namespace in /usr/local/lib/

Anyone have any ideas?


When building with CMake you need to make sure that the source tree do not have leftovers from the traditional build, in particular generated dictionaries. The error you are getting is probably due to some unwanted fragment of a dictionary being added into the PyROOT library. Remove any G__xxxx.cxx,.h from the source tree.