pyRoot on OS X Maverick

Hello, I managed to compile / install a version on root on OS X Maverick with the following steps:

git clone http://root.cern.ch/git/root.git temp/ROOT
cd temp/ROOT/
git checkout -t origin/v5-34-00-patches
./configure --all
make
. bin/thisroot.sh 

The installation seems to work. However, when I try

I get the following error:

>>> import ROOT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tobin/temp/ROOT/lib/ROOT.py", line 257, in <module>
    _root.gPad         = _ExpandMacroFunction( "TVirtualPad",  "Pad" )
  File "/Users/tobin/temp/ROOT/lib/ROOT.py", line 237, in __init__
    c = _root.MakeRootClass( klass )
AttributeError: type object 'string' has no attribute 'c_str'

The following, however, works fine:

Do you know why?

Thanks,
Mark

Mark,

as also per the other topic … I’ve not completely moved to 10.9 yet; once there I can test.

Cheers,
Wim

This issue is still present in ROOT v5-34-11 on OS X 10.9.
In IPython the error looks like this:
gist.github.com/cdeil/7291259

Hi,

fixed in v5-34-00-patches. The dictionary for ‘std::string’ is not loaded (and std::string isn’t available in the first place, only ‘string’ which is also a python module, hence that specific error as the module hasn’t a c_str()).

Cheers,
Wim

Another problem I have encountered is that .Draw() is not showing the XQuartz window. However .Print(“xy.pdf”) works fine.

example:

import ROOT as rt

c = rt.TCanvas("", "", 700, 500)
a = rt.TH1F("a", "a", 10, 0, 2)
a.Draw()
raw_input()
c.Print("a.pdf")

I get no error, just

# python test.py

Info in <TCanvas::Print>: pdf file a.pdf has been created

Hi,

that’s odd, as a TCanvas was one of the things that I tried. Did you configure for cocoa? If so, can you try this option of driving the GUI instead (should be the first lines):import ROOT ROOT.PyConfig.StartGuiThread = 'inputhook'
Cheers,
Wim

I did not enable anything special, I just did a plain

Hi,

okay, but did setting the option help?

I’ll try again myself once I’m behind a Mac.

Cheers,
Wim

I tried it, but it changed nothing. It’s really strange that I get no errors while I don’t even see the window pop up, when I create a new TCanvas.
I’ll try to configure for cocoa tomorrow, maybe that will work.

Hi,

btw., does root.exe show a window for you? Or for that matter xclock or any simple application? I.e., is it an XQuartz problem or a Python problem? When searching the interwebs, I’m finding several reports of X11 applications having trouble and the only remedy posed seems to be to reinstall XQuartz (presumably this restores/recreates some files that the update destroyed).

Cheers,
Wim

I just tried to create a TCanvas in the root interpreter, it shows up as expected. But if I want to draw something to that Canvas, I get the same error as in this thread Linker problem with Mac OS 10.9 and libAfterImage

[quote=“dhill”]I’m not sure why it won’t work in my case, strange…

Just to document what I see currently, I get the error message:

*** Break *** bus error
Generating stack trace…
0x000000010d6ec5e2 in TGX11TTF::RenderString(int, int, TVirtualX::ETextMode) (in libGX11TTF.so) + 706
0x000000010a980645 in TPad::PaintText(double, double, char const*) (in libGpad.so) + 101
0x000000010a592fbf in TLatex::Analyse(double, double, TextSpec_t, char const*, int) (in libGraf.so) + 46063
0x000000010a594e23 in TLatex::PaintLatex(double, double, double, double, char const*) (in libGraf.so) + 4147
0x000000010a57e91a in TGaxis::PaintAxis(double, double, double, double, double&, double&, int&, char const*, double, bool) (in libGraf.so) + 27274
0x0000000151a3b376 in THistPainter::PaintAxis(bool) (in libHistPainter.so) + 2102
0x0000000151a3a23a in THistPainter::Paint(char const*) (in libHistPainter.so) + 1866
0x000000010a97d369 in TPad::Paint(char const*) (in libGpad.so) + 601
0x000000010a97d369 in TPad::Paint(char const*) (in libGpad.so) + 601
0x000000010a9826d9 in TPad::Print(char const*, char const*) (in libGpad.so) + 6121
0x000000010a983a2d in TPad::SaveAs(char const*, char const*) const (in libGpad.so) + 1021
0x0000000108b44c1a in Fitting::RunFullFit(bool) (in run) (Fitting.C:1156)
0x0000000108b357d9 in Fitting::Fitting(Parameters*, TApplication*) (in run) (Fitting.C:160)
0x0000000108b2a974 in main (in run) (ostream:1180)
0x00007fff910185fd in start (in libdyld.dylib) + 1
0x0000000000000009 in

right at the point where my code attempts to draw stuff onto a TCanvas. It creates the TCanvas objects and I see them blank on my screen, but it crashes shortly after.[/quote]

edit to answer your post: XQuartz is working with other applications, I don’t think this is the problem.

Hi,

I have the same problem: after installing the latest root-v5-34-00-patches, I do not get any X windows in python. So when I do:

from ROOT import *
TBrowser()

Nothing happens. I tried the suggestion from Wim to drive the GUI (I tried this both for XQuartz and cocoa), but that does not help either.

Any suggestion is much appreciated.

Jeroen

I’m having the same problem as jvantilb on the 5-34-00-patches release

I’ve also installed through macports – This leads to the having to import ROOT twice problem,
I added the lines:

   if sys.platform == 'darwin':                                                                                        
     _root.gROOT.ProcessLine( '#include <string>' )   

in class std( object ) (about line 228) in ROOT.py
which solves the import ROOT twice issue, but then XQuartz does not open, similar to the 5-34-00 patches problem

Hi,

can each who has issues with X11 verify their config.status to see where X11 headers and libs are picked up from? I’ve a problem Mac where they are picked up from an old (pre-Mavericks) Macports installation. Might be the reason.

Cheers,
Wim

[quote=“wlav”]Hi,

can each who has issues with X11 verify their config.status to see where X11 headers and libs are picked up from? I’ve a problem Mac where they are picked up from an old (pre-Mavericks) Macports installation. Might be the reason.

Cheers,
Wim[/quote]

I did a clean install of OS X Mavericks, Command Line Tools and XQuartz. I don’t think that’s the issue.

./configure macosx64 --all: http://nopaste.me/paste/59816096527a8996c0b2e

➜  root git:(v5-34-00-patches) # ls -l /usr/X11*
lrwxr-xr-x  1 root  wheel  8  2 Nov 10:00 /usr/X11 -> /opt/X11
lrwxr-xr-x  1 root  wheel  8  2 Nov 10:00 /usr/X11R6 -> /opt/X11

Hi,

which version of XQuartz do you have? Their docs (xquartz.macosforge.org/trac/wiki) say:[quote]Mavericks users, please use 2.7.5 rc3 or later.[/quote]
Cheers,
Wim

Btw., I just reinstalled XQuartz and now at least xclock works. No root.exe or PyROOT windows, though.

Cheers,
Wim

Hi,

here is something: for whatever reason, when I start PyROOT, I get this:[code]>>> import ROOT

print ROOT.gROOT.IsBatch()
True
[/code]
Even more surprising, when I do:>>> import ROOT ROOT.gROOT.SetBatch(False) c = TCanvas()
everything seems to work fine.

No idea why the default setting has changed in side ROOT or what is causing that change.

Note that this is after reinstalling XQuartz (2.7.5 rc4), so that may have had other effects (before xclock didn’t work for me either, for example).

Cheers,
Wim

[quote=“wlav”]
Even more surprising, when I do:[code]>>> import ROOT

ROOT.gROOT.SetBatch(False)
c = TCanvas()[/code]
everything seems to work fine.[/quote]
Yes, I that works, but try to draw something to that TCanvas

import ROOT
ROOT.gROOT.SetBatch(False)
c = ROOT.TCanvas()
h = ROOT.TH1F()
h.Draw()

I use XQuartz 2.7.5 rc4.

Hi,

I’ll try later … currently everything is broken while I’m trying to upgrade ports. I had to give up, wipe the system, and start over. May take a bit, as I won’t be behind a mac for the rest of the day.

Cheers,
Wim