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.
mkdir ~/Software;cd ~/Software
svn co http://root.cern.ch/svn/root/trunk 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/
make[/code]
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
make[/code]
(ref [url]https://root-forum.cern.ch/t/install-issue-symbol-missing/11179/1 )
And finally
[code]. bin/thisroot.sh
export LD_LIBRARYPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib:$LD_LIBRARYPATH
export PYTHONPATH=$ROOTSYS/lib:$PYTHONPATH
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 ROOT.py anywhere on your system. In my case I find a copy in /Users/myusername/Software/root/lib/ROOT.py (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 ROOT.py, but try to figure out what the error messages are telling you.
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 ROOT.py in my /bindings/pyroot folder under my ROOTSYS path
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/ROOT.py", line 85, in <module>
import libPyROOT as _root
ImportError: dlopen(/usr/local/lib/libPyROOT.so, 2): Symbol not found: __ZN10TSSLSocket11ShowMembersER16TMemberInspector
Referenced from: /usr/local/lib/libNet.so
Expected in: flat namespace
in /usr/local/lib/libNet.so
Hi,
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.