Hi Root Expert,
I experienced a couple of import errors when running this simple code:
import ROOT
# To mark a Python callable to be used from C++, you have to use the decorator
# provided by PyROOT passing the C++ types of the input arguments and the return
# value.
@ROOT.Numba.Declare(['float', 'int'], 'float')
def pypow(x, y):
return x**y
# The Python callable is now available from C++ in the Numba namespace.
# For example, we can use it from the interpreter.
ROOT.gInterpreter.ProcessLine('cout << "2^3 = " << Numba::pypow(2, 3) << endl;')
# Or we can use the callable as well within a RDataFrame workflow.
data = ROOT.RDataFrame(4).Define('x', '(float)rdfentry_')\
.Define('x_pow3', 'Numba::pypow(x, 3)')\
.AsNumpy()
print('pypow({}, 3) = {}'.format(data['x'], data['x_pow3']))
when running with the default python 2.7.5, I got:
Traceback (most recent call last):
File “…/test.py”, line 10, in
@ROOT.Numba.Declare([‘float’, ‘float’], ‘float’)
File “/usr/lib64/python2.7/site-packages/ROOT/_facade.py”, line 316, in Numba
raise Exception(‘ROOT.Numba requires Python above version {}.{}.{}’.format(*_numba_pyversion))
Exception: ROOT.Numba requires Python above version 2.7.5
Then I switched to python3.6, and I got longer errors: raceback (most recent call last):
File “/usr/lib64/python3.6/site-packages/ROOT/_numbadeclare.py”, line 28, in _NumbaDeclareDecorator
import numba as nb
File “/usr/lib64/python3.6/site-packages/ROOT/_facade.py”, line 150, in _importhook
return _orig_ihook(name, *args, **kwds)
ModuleNotFoundError: No module named ‘numba’During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “…/test.py”, line 10, in
@ROOT.Numba.Declare([‘float’, ‘float’], ‘float’)
File “/usr/lib64/python3.6/site-packages/ROOT/_numbadeclare.py”, line 30, in _NumbaDeclareDecorator
raise Exception(‘Failed to import numba’)
Exception: Failed to import numba
ROOT Version: 6.24/06
Platform: lxplus7
Compiler: Not Provided
Appreciate it if you could have a look and give me a hand!
Thanks,
Jordan