Hello everyone,
I am working with PyROOT in my master thesis and I got some messy code to work with which is not formatted correctly according to pep8. I thought in the process of going through the code I could try to “correct” the code and format it properly.
The following is just a question of interest which I was not able to figure out.
While I have no problems with the command
import ROOT
There is a warning when I try for example
from ROOT import TTree
which is “no-name-in-module: no name ‘TTree’ in module ‘ROOT’”. The code compiles without a problem, I was just wondering how I can add the modules of ROOT to my PYTHONPATH variable so that they are seen. The variable is currently set to
<installdir>/root/lib
but apparently the modules are not listed there for python, I guess. Is there a workaround to fix this “problem”?
What version of ROOT are you using? How did you install ROOT?
TTree is provided out-of-the-box in PyROOT, so a failure in looking it up indicates there is some problem with the ROOT installation / the configuration of the environment.
I first tried to build it, but this did not work out of the box for me, so I deleted the files and used the pre-compiled binary distribution for Ubuntu 20. I am using Ubuntu 20.04.1. I created a directory in my home directory .ROOT and unpacked the files to it. Afterwards I sourced thisroot.sh.
Ok, so you get that message from pylint, not from the Python interpreter when you try to run the code, right?
The thing with PyROOT is that everything is dynamic, there is no TTree Python class that is created beforehand. What happens is that, by interrogating the ROOT C++ interpreter, PyROOT can learn about C++ entities (e.g. classes) at runtime and create Python proxies for them. That must be the reason why you get that message from pylint, since there is no TTree class in the PYTHONPATH, it’s created on the fly.