“No name in module” error from Pylint

Each Answer to this Q is separated by one/two green lines.

I have a file named main.py with the following code:

#!/usr/bin/env python3

import utils.stuff

if __name__ == "__main__":
    print("hi from main.py")

In the directory with main.py, I have a subdirectory named utils which has a file named stuff.py with the following code:

print("hi from stuff.py")

def foo():

If I run ./main.py from the command line, I get the following output:

hi from stuff.py
hi from main.py

That is exactly what I expect. However, if I run pylint main.py, I get the following output:

No config file found, using default configuration
************* Module main
C:  1, 0: Missing module docstring (missing-docstring)
E:  3, 0: No name 'stuff' in module 'utils' (no-name-in-module)
E:  3, 0: Unable to import 'utils.stuff' (import-error)
E:  7, 4: Module 'utils' has no 'stuff' member (no-member)

followed by some more detailed statistics that do not seem relevant to my question. Why is this happening? What can I do to make Pylint aware of utils/stuff.py? I am running Python 3.5.2, Pylint 1.6.4 and OS X 10.11.6.

You need a create utils/__init__.py. This will make python aware of the submodule and also allows you to run any code you want to happen on import. If you don’t want anything to run then just include a docstring.

I got this error when my function was named start:

from views import start

It worked when I changed the name of the function.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .