Pyroot and Eclipse root 6

Hi rooters,

I have the following problem with root 6 and eclipse using pyroot. When running my code in eclipse I receive the following error:

[color=#FF0000]Traceback (most recent call last):
c = libPyROOT.MakeRootClass( ‘PyROOT::TPyROOTApplication’ )
AttributeError: ‘module’ object has no attribute ‘MakeRootClass’[/color]

This is my code:

[code]from ROOT import TCanvas, TH1F
import sys
import libPyROOT

argv = sys.argv
sys.argv = []

if name == ‘main’:
print "!!!Hello ROOT!!!"
c = libPyROOT.MakeRootClass( ‘PyROOT::TPyROOTApplication’ )
c.CreatePyROOTApplication()

c1 = TCanvas("c1","test", 600,600);
hist = TH1F("test", "test", 100,0,1);
hist.Fill(0.1);
hist.Fill(0.5);
hist.Draw();
del argv

del c1;

[/code]

Thanks.

Michael

Michael,

just remove those lines:import libPyROOTand:c = libPyROOT.MakeRootClass( 'PyROOT::TPyROOTApplication' ) c.CreatePyROOTApplication()
Besides these being unsupported internals, the CreatePyROOTApplication call is a no-op in the way you’re using it here (the TPyROOTApplication is already created b/c of “from ROOT import …”).

Cheers,
Wim

Hi Wim,

Thanks a lot for the hint. The reason using it was that I can see the histogram. Not using it the Histogram closes it right away. Which way can I use to still see the output/Histogram when running my code in eclipse?

Thanks.

Cheers,

Michael

Michael,

the canvas closes b/c Python exits. That behavior can not be explained with those lines, as they are truly a no-op if gApplication already exists.

I haven’t touched eclipse for years, so not sure what is the best course of action, but to keep the script alive, drop into interactive mode, wait for input (‘raw_input()’), or enter ‘ROOT.gApplication.Run()’.

Cheers,
Wim

Hi Wim,

with ROOT.gApplication.Run() it worked out. Thanks.

Best regards,

Michael