# Pylint error "no-name-in-module"

**URL:** <https://root-forum.cern.ch/t/pylint-error-no-name-in-module/41651>\
**Category:** Newbie\
**Created:** [September 30, 2020, 11:33am UTC](https://root-forum.cern.ch/t/pylint-error-no-name-in-module/41651 "2020-09-30T11:33:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![no\_pro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/67e7ee/32.png) [@no\_pro](https://root-forum.cern.ch/u/no_pro)\
**Post date:** [September 30, 2020, 11:33am UTC](https://root-forum.cern.ch/t/pylint-error-no-name-in-module/41651/1 "2020-09-30T11:33:58Z")

</div>

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

```auto
import ROOT

```

There is a warning when I try for example

```auto
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”?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [October 1, 2020, 3:05pm UTC](https://root-forum.cern.ch/t/pylint-error-no-name-in-module/41651/2 "2020-10-01T15:05:17Z")

</div>

Hello,

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.

---

<div class="post-metadata">

**Author:** ![no\_pro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/67e7ee/32.png) [@no\_pro](https://root-forum.cern.ch/u/no_pro)\
**Post date:** [October 2, 2020, 7:48am UTC](https://root-forum.cern.ch/t/pylint-error-no-name-in-module/41651/3 "2020-10-02T07:48:14Z")

</div>

I am using ROOT Version 6.22/02.

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.

The python version I am using is 3.8.2.

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [October 2, 2020, 8:18am UTC](https://root-forum.cern.ch/t/pylint-error-no-name-in-module/41651/4 "2020-10-02T08:18:02Z")

</div>

What you are doing looks ok.

Can you try a few things?

- Does the ROOT prompt (C++) work? Can you use TTree from there?
- What happens if you execute:

```auto
import ROOT
ROOT.TObject

```

does that give you the same lookup error as for TTree?

---

<div class="post-metadata">

**Author:** ![no\_pro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/67e7ee/32.png) [@no\_pro](https://root-forum.cern.ch/u/no_pro)\
**Post date:** [October 2, 2020, 11:07am UTC](https://root-forum.cern.ch/t/pylint-error-no-name-in-module/41651/5 "2020-10-02T11:07:00Z")

</div>

Just to clarify:

The code compiles also in PyROOT without a problem, so the modules are ready to use.

It is just a formal problem I was wondering about, since pylint does not find all modules of ROOT.

The only modules that are found by pylint are:

cppyy, sys, importlib, major, minor, librootpyz\_mod\_name, pyz, functools, pkgutil, pythonization, exclude, module\_name, module, builtins, ip, JupyROOT, JsMVA, atexit, cleanup, environ, path, ROOTFacade, get\_ipython

which I get from the pylint error message when I type

```auto
from ROOT import *

```

as “unused-wildcard-import”.

Thus,

```auto
import ROOT
ROOT.TObject

```

gives the same lookup error.

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [October 2, 2020, 2:23pm UTC](https://root-forum.cern.ch/t/pylint-error-no-name-in-module/41651/6 "2020-10-02T14:23:29Z")

</div>

Hi,

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.
