Sharedtest_pyroot.ipynbOpen in CoCalc
Authors: Enol Fernández, Enrico Guiraud, Samuel Lelièvre, Harald Schilly, William A. Stein, Efrain T
Views : 7
Description: Try PyROOT in Jupyer in CoCalc
In [1]:
import ROOT
In [2]:
ROOT.__file__
'/usr/lib/python2.7/dist-packages/ROOT.pyc'
In [3]:
import pyroot
ImportErrorTraceback (most recent call last) <ipython-input-3-bcb5f33d6f78> in <module>() ----> 1 import pyroot /usr/lib/python2.7/dist-packages/ROOT.pyc in _importhook(name, *args, **kwds) 350 except Exception: 351 pass --> 352 return _orig_ihook( name, *args, **kwds ) 353 354 __builtin__.__import__ = _importhook ImportError: No module named pyroot
In [4]:
import os import sys
In [5]:
b = sys.path
In [6]:
b
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/cocalc/lib/python2.7/site-packages', '/usr/lib/python2.7/dist-packages/libsbml', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/wx-3.0-gtk2', '/usr/local/lib/python2.7/dist-packages/IPython/extensions', '/home/user/.ipython']
In [7]:
pwd
u'/home/user'
In [8]:
sys.path = ['/projects/d552e619-3c8e-4722-bda1-8f6a75f78443/Programs/myroot/lib'] + b
In [9]:
sys.path
['/projects/d552e619-3c8e-4722-bda1-8f6a75f78443/Programs/myroot/lib', '', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/cocalc/lib/python2.7/site-packages', '/usr/lib/python2.7/dist-packages/libsbml', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/wx-3.0-gtk2', '/usr/local/lib/python2.7/dist-packages/IPython/extensions', '/home/user/.ipython']
In [10]:
import ROOT
In [11]:
ROOT.__file__
'/usr/lib/python2.7/dist-packages/ROOT.pyc'
In [12]:
h = ROOT.TH1F("gauss","Example histogram",100,-4,4)
In [13]:
h.FillRandom("gaus")
In [14]:
c = ROOT.TCanvas("myCanvasName","The Canvas Title",800,600)
In [15]:
h.Draw()
In [16]:
c.Draw()
In [17]:
ROOT.enableJSVis() c.Draw() #ROOT.disableJSVis()
AttributeErrorTraceback (most recent call last) <ipython-input-17-b10217d8d1b9> in <module>() ----> 1 ROOT.enableJSVis() 2 c.Draw() 3 #ROOT.disableJSVis() /usr/lib/python2.7/dist-packages/ROOT.pyc in __getattr2(self, name) 484 485 # lookup into ROOT (which may cause python-side enum/class/global creation) --> 486 attr = _root.LookupRootEntity( name ) 487 488 # the call above will raise AttributeError as necessary; so if we get here, AttributeError: enableJSVis
In [ ]: