Yet another ipython problem

I have a problem with ipython not playing nicely with pyROOT. My post to the ipython-user list can be found here: … 07228.html
The problem is the following.
PyROOT in a normal python session works flawlessly, but in ipython the following gives problems:
In [1]: from ROOT import *
In [2]: g=TGraph()

NameError: name ‘TGraph’ is not defined
So for some reason this does not work in ipython.
The strange thing is that the following works fine in ipython;
In [1]: import ROOT
In [2]: g=ROOT.TGraph()
Works and g is completely usable as a ROOT graph object.
The following also works:
In [1]: from ROOT import TGraph
(Bool_t) 1
In [2]: g=TGraph()
(I only used TGraph as an example. The problem is general for all ROOT classes)

Some information:
I am on a 64bit Mac using OSX10.6 and the standard installation of python.

Does anyone have an idea what could cause this?


I have this problem too. My solultion: don’t use from ROOT import * !

Sorry, I don’t know how to fix it. I don’t use the interactive stuff all that much anyway, but it is a little annoying.



for “from ROOT import *” to work lazily, it modifies the dictionary lookup of the calling frame (in most polite company, that’s considered a hack, but it works exceedingly well compared to the usual “trick” of modifying the exception handler). The indirection that ipython seem to add, makes that impossible however, since the next statement will be executed in a different frame than the previous statement.

Not sure if the “user_namespace” is made available by ipython, as it is possible to give the dictionary whose lookup needs to be modified to “ROOT.SetRootLazyLookup()” and work from there.