Problem import ROOT.py on Mac OS X

Hi,

I’m going to see whether I can get hold of a Tiger on Monday (several of my colleagues use it, but it’s usually their main machine, so they may be reluctant :slight_smile: ).

There’s nothing more that I can do, until it is possible to reproduce the problem.

Cheers,
Wim

I did “make install”. But I didn’t “make map”.
Well, I will try to ‘make map’ again.
:cry: The same error.

  1. cvs checkout
  2. ./configure macosx --prefix=/Users/exaos/Opt/root/current --datadir=/Users/exaos/Opt/root/current/share --etcdir=/Users/exaos/Opt/root/current/etc --elispdir=~/.emacs.d/site-lisp --incdir=/Users/exaos/Opt/root/current/include --libdir=/Users/exaos/Opt/root/current/lib --docdir=/Users/exaos/Opt/root/current/doc --enable-python --enable-cern --enable-fftw3 --enable-mathcore --enable-mathmore --enable-minuit2 --enable-opengl --enable-xml --enable-shared --enable-roofit --enable-reflex --enable-table --with-cern-libdir=/sw/lib
  3. make
  4. make map
  5. make install

Then,

~>$ /usr/local/bin/python
Python 2.4.3 (#1, Mar 30 2006, 11:02:15)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/Users/exaos/Opt/root/current/lib/ROOT.py", line 74, in ?
    from libPyROOT import *
ImportError: Inappropriate file type for dynamic loading

I’m sure that $ROOTSYS/lib is in my $LD_LIBRARY_PATH, $DYLD_LIBRARY_PATH and $PYTHONPATH. And anything else?
Can anyone reproduce the problem?[/code]

Hi,

ok, took a while, but I managed to get my hands on a 10.4.6 machine. I don’t have much time anymore today, but will report asap.

Cheers,
Wim

Hey folks,

ok, managed to reproduce and work around the problem. It is in the python installation itself. For reasons that I do not know (it is hard-wired for Darwin in the configure script), the python 2.4 install uses dynload_next.o rather than dynload_shlib.o as is used by the Tiger out-of-the-box python 2.3 install (both dynload_next.c and dynload_shlib.c are part of the python distribution). Modifying the python 2.4 Makefile and rebuilding did the trick.

For your installers, you can probably use the setting of an environment variable (I tested running “./configure --enable-shared --enable-framework” and saw that it was picked up). Please do:$ export DYNLOADFILE=dynload_shlib.oor the equivalent setenv if you’re running a shell in the *csh family. After, or preferably before, building, verify that the produced Makefile has the right value (do “grep DYNLOADFILE Makefile”), or change it by hand and rebuild.

HTH,
Wim

Hi Wim

I’ve rebuilt my python with the following in the configure environment

DYNLOADFILE=dynload_shlib.o

and with building ROOT against this python ROOT.py imports without issue!

[code][ram@zebedee ram]$ python
Python 2.4.3 (#1, May 19 2006, 11:59:36)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT

[/code]

Thanks for all the help!

Adam

After rebuilding Python 2.4.3 as mentioned above, everything is OK. :slight_smile:

Hi, I have a macbook and an intel Imac, and I have the same problem with the universal macpython on both, so I tried to rebuild it as suggested. The problem is that if I “./configure --enable-framework” for python 2.4.3 and then make it, I get the error

[quote]/usr/bin/ld: warning Python.framework/Versions/2.4/Python cputype
(18, architecture ppc) does not match cputype (7) for specified -
arch flag: i386 (file not loaded)[/quote]

I don’t have such error if I don’t configure python as framework, but unfortunately the framework seems necessary.
I have been exchanging some emails with the python support but they could’t replicate the problem, so I’d like to ask you. How did you manage to rebuild python on intel mac?

thanks a lot
Emanuele

Emanuele,

sorry, I don’ t have access to an Intel mac. Not sure whether any of my colleagues already have them (one does, but he’s leaving for CERN again tomorrow).

Note that it isn’t per se necessary to install a framework, just that I had best experience with that and so recommend it. However, I’ve also been successful with installation under /sw with Fink. In that case, you can specify the include (location of Python.h) and library (location of libpythonx.y) directories explicitly with --with-python-incdir=… and --with-python-libdir=… as arguments to ./configure.

Cheers,
Wim

Hi again Wim, this is becoming a bit frustrating, I tried many options and rebuilt everything so many times…I tell you what I’ve done:

1.Installing python (not as a framework, else it fails)

export DYNLOADFILE=dynload_shlib.o ./configure make -j2 make install (as root)

it installs python in /usr/local

2.installing root:

[code]./configure macosx --enable-python --with-python-incdir=/usr/local/include/python2.4 --with-python-libdir=/usr/local/lib/python2.4/config

make -j2
make install (as root)[/code]

my bash profile (.profile) is

[code]# Setting PATH for Python 2.4
PATH=“/usr/local/bin:${PATH}”
export PATH

ROOT path

export ROOTSYS=/usr/local/root
PATH=“ROOTSYS/bin:{PATH}”
export PATH
export DYLD_LIBRARY_PATH=$ROOTSYS/lib
export MANPATH=$ROOTSYS/man
export PYTHONPATH=$ROOTSYS/lib[/code]

so: now everything seems to work smoothly: python starts with the right version and root starts perfectly but when I import root fro python I get a new error:

[code]Python 2.4.3 (#1, Jun 30 2006, 11:44:46)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

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

any idea about it?

Emanuele,

this environment variable:export DYLD_LIBRARY_PATH=$ROOTSYS/lib
should contain the path to the newly installed libpython.so as well (/usr/local/lib if I understand your posting correctly). If there is no shared library (should be there by default since p2.3), you can use --enable-shared when configuring the python source for build.

HTH,
Wim

nope, didn’t work unfortunately.here is what I did

python:

export DYNLOADFILE=dynload_shlib.o ./configure --enable-shared make -j2 sudo make install

root:

[code]./configure macosx --enable-python --with-python-incdir=/usr/local/include/python2.4 --with-python-libdir=/usr/local/lib/python2.4/config --enable-shared

make -j2
sudo make install[/code]

bash profile: same as before but

export  DYLD_LIBRARY_PATH=/usr/local/root/lib:/usr/local/lib

result:
root starts, python starts but:

[code]Python 2.4.3 (#2, Jun 30 2006, 23:58:40)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap
[/code]
or did I misunderstand something?
cheers,
Emanuele

Emanuale,

that looks right … could you use “otool -L libPyROOT.so” to see whether it has been linked properly with /usr/local/lib/libpython2.4.so?

Cheers,
Wim