E0611 no-name-in-module

Message

'No name %r in module %r'

Description

Used when a name cannot be found in a module.

When you import a name from a module which cannot be found in the target module.

There can be false positive issues of the type when

  • pylint is run with an incompatible python version

  • pylint is run in an environment that misses a depedency of your code (this is more likely to lead to issues of type import-error (E0401))

  • the name you are importing is in turn imported into the target module by a wildcard import

Examples

In the following example the (non-existent) name not_there is imported from os.

from os import not_there
1:0: E0611: No name 'not_there' in module 'os'

False positive: Incompatible python version

This example shows what happens when we run pylint using Python 3 while our code targets Python 2.

# this works in Python 2
from urllib import urlencode
2:0: E0611: No name 'urlencode' in module 'urllib'

False positive: Wildcard import

In the following example, we run pylint in an enviroment where we miss the dependecy that provides the module some_lib.

from .other_module import some_name
# other_module.py
from some_lib import *
1:0: E0611: No name 'some_name' in module 'pkg.other_module'

Running Pylint locally? In your CI?

There is a better way! Run PyCodeQual & get Pylint findings with history, diffs and statistics.

Click here to find out more.