Proper relative imports: "Unable to import module" Proper relative imports: "Unable to import module" python-3.x python-3.x

Proper relative imports: "Unable to import module"


The error you are receiving is one that's reported by a python linter named pylint. So the problem isn't really specific to the vscode extension.

There are two solutions:

  1. Please try adding an .env file in your project directory with the vape PYTHONPATH=./myapp, this will tell pylint where to find your modules

  2. Or just open the folder myapp in vscode directly instead of opening the parent directory in vscode.


The error is coming from pylint. You need to add this line into settings.json file (VS Code):

"python.linting.pylintArgs": ["--init-hook",        "import sys; sys.path.append('<absolute path to myapp directory>')"],


Since hello.py and world.py are in the same folder (aka package), you should import the Hello class in world.py as follow:

from .hello import Hello

As described in this thread: What does a . in an import statement in Python mean?

The . is here to indicate the import from the current package.