DEV Community

How to solve Pylance 'missing imports' in vscode

Alin Climente on February 03, 2021

Here is how you can solve this issue: Make sure you selected the right python interpreter for your project (in case you are using virtualenv/pipe...
Collapse
 
miguelcb84 profile image
Miguel Coronado •

In my case, the fastest solution when imports are not missing is to launch vscode from the virtual environment. Basically, activate the venv as always, and then code .

Collapse
 
karanparekh profile image
Karan Parekh •

Thanks for the solution. Just to add, incase of virtual env created from WSL, you need to set the interpreter as shown below.
code.visualstudio.com/docs/python/....

Collapse
 
carloswm85 profile image
Carlos •

Is there any way to include as a path ALL of the folders below a given path? I'm working inside a folder, with several subfolders, each of them with its own test. This solution solves the problem by adding each individual folder to the extraPaths, every time, but no for a group of folders.

Collapse
 
climentea profile image
Alin Climente •

Please comment if you find the solution. I am interested in this too :)

Collapse
 
karanparekh profile image
Karan Parekh •

Wild card paths (/) should work something like `folder1/folder2/`
But I am not sure..

Collapse
 
gregorywaynepower profile image
Gregory Power •

I had this issue as well. I selected my Python Interpeter to my conda/mamba environment. But the only thing that worked was Ctrl + Shift + P , Python: Clearing Cache & Reload Workbook

Collapse
 
solomonxuche profile image
Solomon Uche •

What is the app folder

Collapse
 
phideasambrosianus profile image
PhideasAmbrosianus •

Adding a note here. You may need to re-select the interpreter after you've run pip to install a new library. Just re-selecting the same thing (instead of changing versions) worked for me. Presumably restarting the app does same thing, but who wants to do that?

Collapse
 
jmahendr profile image
Joshua Francis •

Thanks, this makes it easier.

Collapse
 
vinijill profile image
Vin •

Thanks for the suggestion. Changing the interpreter solved my problem...

Collapse
 
siggib007 profile image
Siggi Bjarnason •

In my case I'm getting this error just on requests , not on anything else. My interpreter is selected correctly from what I can tell and always has been. The code runs fine from within VSCode too.

Collapse
 
siggib007 profile image
Siggi Bjarnason •

Looks like adding c:\program files\python310\lib\site-packages to analysis.extraPaths did the trick for me.

Collapse
 
happeecoder profile image
Anandh Happeecoder •

Thank you very much

Collapse
 
xlibraboy profile image
Budi Kurniawan •

wow, just change interpreter from 3.9.5 to 3.9.4, tadaaa... its working now, thank you so much