DEV Community

loading...

How to solve Pylance 'missing imports' in vscode

climentea profile image Alin Climente ・1 min read

Here is how you can solve this issue:
pylance_import_issue

Make sure you selected the right python interpreter for your project (in case you are using virtualenv/pipenv/other):
pythonenv

When you run pipenv shell, you will see which python interpreter is used. A folder named .vscode will be created once you select a different interpreter than the default one. Inside .vscode you will have a settings.json file.

In settings.json file you have to add the paths from which you import what's needed in extraPaths:

{
    "python.pythonPath": "/home/youruser/.virtualenvs/app-FzQGSFjf/bin/python",
    "python.analysis.extraPaths": ["app", "another/path/etc"]
}
Enter fullscreen mode Exit fullscreen mode

In my case, app folder was not known by Pylance.

Discussion (0)

pic
Editor guide