I’m getting some errors while running a script in python:
1.unknown type name ‘from’
2.expected ‘;’ after top level declarator**
from array import array
etc
here is the code:
from array import array
import ROOT
myFile = ROOT.TFile.Open(“simplify.root”, “RECREATE”)
tree = ROOT.TTree(“tree”, “newt”)
Provide a one-element array, so ROOT can read data from this memory.
var = array(‘f’, [ 0 ])
tree.Branch(“branch0”, var, “mass”)
for iEntry in range(1000):
var[0] = 0.3 * iEntry
# Fill the current value of ‘var’ into ‘branch0’
tree.Fill()
Now write the header
tree.Write()
Hello @wolfram420,
welcome to the ROOT forum!
Could you please attach the full error output?
Cheers
Monica
Here is the output:
root [0] .L simp.py
In file included from input_line_8:1:
/afs/ihep.ac.cn/users/c/caoxiaojie/Desktop/simp.py:1:1: error: unknown type name ‘from’
from array import array
^
/afs/ihep.ac.cn/users/c/caoxiaojie/Desktop/simp.py:1:11: error: expected ‘;’ after top level declarator
from array import array
^
;
/afs/ihep.ac.cn/users/c/caoxiaojie/Desktop/simp.py:7:3: error: invalid preprocessing directive
Provide a one-element array, so ROOT can read data from this memory.
^
/afs/ihep.ac.cn/users/c/caoxiaojie/Desktop/simp.py:13:7: error: invalid preprocessing directive
Fill the current value of ‘var’ into ‘branch0’
^
/afs/ihep.ac.cn/users/c/caoxiaojie/Desktop/simp.py:16:3: error: invalid preprocessing directive
Now write the header
Cheers
Lisa
You’re trying to execute a python script using a C++ JIT compiler
You should run something like python simp.py
Thanks for your reply. The problem is solved 