pyROOT for Mac

Hi,

I’m currently trying to install pyROOT in my Mac (OS X 10.6.7, arch i386). So far, I have managed to install root from source with:

ftp://root.cern.ch/root/root_v5.28.00c. … 4.2.tar.gz

and if I start root from the terminal:

root

it all works. But the problem is when I try to use pyROOT, I get the following error:

python -i
python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT
Traceback (most recent call last):
File “”, line 1, in
File “lib/ROOT.py”, line 85, in
import libPyROOT as _root
ImportError: dlopen(/Users/tsandoval/phd/root/lib/libPyROOT.so, 2): no suitable image found. Did find:
/Users/tsandoval/phd/root/lib/libPyROOT.so: mach-o, but wrong architecture
/Users/tsandoval/phd/root/lib/libPyROOT.so: mach-o, but wrong architecture

Indeed if one does:

file which root
/Users/tsandoval/phd/root/bin/root: Mach-O executable i386

file which python
/usr/bin/python: Mach-O universal binary with 3 architectures
/usr/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/python (for architecture i386): Mach-O executable i386
/usr/bin/python (for architecture ppc7400): Mach-O executable ppc

So python has 3 different architectures it seems! I’ve googled this problem but nothing really useful comes across. Can you please help me?

Thanks,

Tanya

Tanya,

not a Mac expert here, but it looks to me like your system is really x86_64, not i386. But now with i386 selected, I think you can still run by doing:[code]$ arch -i386 python

import ROOT
[/code]
Cheers,
Wim

Hi Wim,

Thanks but that doesn’t work for me either… I have tried the following:

  1. Installing root_v5.28.00c.macosx106-x86_64-gcc-4.2.tar, then ‘arch -x86_64 python’ and ‘arch -i386 python’ for which I get the following error in both cases:

import ROOT
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap

  1. Installing root_v5.28.00c.macosx106-i386-gcc-4.2.tar and then doing ‘arch -i386 python’ and ‘arch -x86_64 python’ for which I get the following error for both cases:

import ROOT
Traceback (most recent call last):
File “”, line 1, in
File “lib/ROOT.py”, line 85, in
import libPyROOT as _root
ImportError: dlopen(/Users/tsandoval/phd/root/lib/libPyROOT.so, 2): no suitable image found. Did find:
/Users/tsandoval/phd/root/lib/libPyROOT.so: mach-o, but wrong architecture
/Users/tsandoval/phd/root/lib/libPyROOT.so: mach-o, but wrong architecture

If I type in my terminal:

arch
I get i386, hence why I was downloading root_v5.28.00c.macosx106-i386-gcc-4.2.tar.

Tanya

Tanya,

the version error I’ve seen mostly when a python library other than the system one was used (with both being loaded), but you are using the system version of python, no?

As for arch returning i386, does so on my system too, but I’d swear it’s 64b. :slight_smile:

Cheers,
Wim

Hi Wim,
Hi Wim,

I am not sure I understand your question:

“but you are using the system version of python, no?”

Since you think my Mac is 64b, your suggestion is to install Installing root_v5.28.00c.macosx106-x86_64-gcc-4.2.tar and then do:

$ arch -i386 python

import ROOT

Is this correct?

Cheers,

Tanya

Tanya,

what I meant was that some people like fink or macports and install their python from there. What then often happens is that version mismatch error that you saw. But I think you’re running the system python? Can you show the result of which python?

As for running, I would have guessed that installing x86_64 should just work with the normal python command, which is why I’d first like to see whether you have the system python (for reference, myself I always run with the system python, unless debugging fink stuff, and build from source using configure with mostly the default sets of variables).

Cheers,
Wim

Hi Wim,

Thanks. The output of which python in my Mac is:

Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

Is this what you expected?

Cheers,

Tanya

Tanya,

sorry, I was looking for the output of “which python” not “which python”. The former gives the location of the python executable, the latter does to but then also starts it.

I don’t have a Mac 10.6 handy, so I don’t know with which version of python it ships. By seeing the path, it’s possible to see whether it’s the version that comes with the OS or a different, later install.

Cheers,
Wim

Hi Wim,

The output of “which python” is /usr/bin/python

Cheers,

Tanya

Also, from what I just posted, perhaps it’s also useful the output of:

ls /usr/bin/python*
/usr/bin/python /usr/bin/python2.5-config /usr/bin/pythonw
/usr/bin/python-config /usr/bin/python2.6 /usr/bin/pythonw2.5
/usr/bin/python2.5 /usr/bin/python2.6-config /usr/bin/pythonw2.6

Cheers,

Tanya

Tanya,

that all looks standard … I’m at a loss as what else could be a problem. The only thing I can further recommend is to build from source instead of installing the binaries.

Cheers,
Wim

Hi Wim,

OK… and how do I ‘build from source’? Is there any guide on how to do this?

Cheers,

Tanya

Tanya,

it’s real easy as the mac should be recognized as a platform and python found automatically. See this article on root.cern.ch: http://root.cern.ch/drupal/content/installing-root-source. Basically: download, untar, run “./configure --prefix=/Users/tsandoval/phd/root” (I’m guessing that prefix from your other postings here), followed by “make” and “make install”.

HTH,
Wim

let’s see if it works or not

Hi,

FWIW: I actually have been dealing with a somewhat similar issue on a Mac today (there was a MacPorts python as newest on the system, and it give wrong architecture errors).

I opted for installing the latest python (shipped is p2.5) from source. For the configuration, I needed teh following set of options (which were new to me):./configure --enable-framework --with-universal-archs=intel --enable-universalsdk=/Developer/SDKs/MacOSX10.5.sdkwhere for newer Macs, you’ll need to select a newer SDK (older ones are usually available and the 10.4 is selected by default, which didn’t work for me). Just have a look whatever is on your system. Follow this with the standard “make && make install” and the resulting python (under /usr/local but also in the /Library/Frameworks location) worked for me.

I then configured ROOT with this newly build python first in $PATH and all worked out-of-the-box.

HTH,
Wim