slothfulwave612
slothfulwave612

Reputation: 1409

Pylint Error: Attempted relative import beyond top-level package

Here in VSCode whenever I write the following line from . import dispatcher pylint always gives error statement saying Attempted relative import beyond top-level package.

But when I run the module using this command: python -m src.train the program runs without flashing any error. Here is the screenshot from the VSCode editor:

enter image description here

Does someone know who to solve this thing in VSCode?

Upvotes: 8

Views: 3011

Answers (1)

Mike1936
Mike1936

Reputation: 101

Just add an empty __init__.py file of the folder that contains your dispatcher.py file, then all the .py files under the folder, as whole, should be recognized as a package. And the lint error should dismiss.

Upvotes: 5

Related Questions