Search code examples
visual-studio-codepylint

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?


Solution

  • 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.