Changing the python library (on OSX)

Hello,

working on OSX 10.9, I compiled ROOT against the OSX python, but afterwards installed python via homebrew. I am also using virtualenv.

When trying to import ROOT in python I get “Fatal Python error: PyThreadState_Get: no current thread”. In a related post [url]Trouble importing pyROOT on OSX 10.9 Mavericks it was proposed (if I understand correctly) to recompile ROOT using the proper library locations.

I am now wondering whether there is a way of not having to recompile ROOT every time I want to change the python version (this would to a certain degree conflict with the idea of having the virtualenv). I was thinking of a solution using some ROOT config file.

Thanks and cheers

Philipp

Philippe,

not all of ROOT needs to be rebuild, only libPyROOT. You can wipe it selectively by doing “make clean-pyroot”. It installs in $ROOTSYS/lib, but it really needs to be only somewhere in $PYTHONPATH, unless you use TPython from cint, in which case it must also be in $LD_LIBRARY_PATH.

To work with virtualenv then, build multiple versions of libPyROOT, one for each python interpreter, and put each in managed locations.

Cheers,
Wim

Hello Wim,

thanks for your reply.

I tried to compile only libPyROOT by looking at the MAKEFILE, but I don’t know make that well . I tried “make bindings/pyroot” and “make rootlibs” and some other commands, but none worked. Do you know the command to only build the libraries? On a similar note, I did not get the “make clean-pyroot” command to work (it does not delete the libPyroot) but instead just used rm lib/libPyroot.*

Is there a reason to use a make clean* type solution?

Also, I was wondering if all of the ROOT code is really included in the one file libPyROOT.so, which I am free to copy anywhere, as long as its being found in the PYTHONPATH? What does the file ROOT.py do?

As you might suspect, I am at the beginning of understanding ROOT and would like to go beyond just using a given setup.

Thanks for your help!

Cheers
Philipp

Philipp,

what I meant was:<configure for python interpreter A> make && make install <move libPyROOT.so to virtualenv managed location> make clean-pyroot <re-configure for python interpreter B> etc. ...that’s the closest thing that there is to “make pyroot-only”.

[quote=“PhilippP”]Also, I was wondering if all of the ROOT code is really included in the one file libPyROOT.so, which I am free to copy anywhere, as long as its being found in the PYTHONPATH?[/quote]No, libPyROOT.so only contains the bindings (and it is linked with several other ROOT libs). You can move it anywhere in PYTHONPATH (assuming you don’t want to use TPython from CINT), though, as it is a python module.

[quote=“PhilippP”]What does the file ROOT.py do?[/quote]It imports libPyROOT, among others. The point is that libPyROOT.so is the only library that depends on the python interpreter (as in: is compiled to a specific set of python includes and linked to a specific python library). Thus, as long as you manage libPyROOT.so through virtualenv, all the rest (all ROOT libs and ROOT.py) can remain in the same location.

Cheers,
Wim

Thanks Wim for clarifying the topic.