Python Auto Import README
Suggest auto import for third-party modules based on modules already imported for Visual Studio Code.
This feature used to be part of VS Code-Pylance but currently does not work anymore.
And while waiting for some updates to fix it/bring it back, I made my extension as a quick workaround.
So, this is to let you know that this extension is just a "quick hack" and might not cover every case (at least for now).
To use the extension, you need to set the python interpreter path to one that has access to the third-party libraries you intend to use in your workspace.
You can set the path in two ways
- Using the extension configuration
- Using the vscode configuration
Note that the extension configuration will override the vscode configuration.
Then after you write a
from module import statement, you should see the modules suggestions based on those imports.
- If not manually changed, most of the time,
python.defaultInterpreterPath will default to the
python interpreter. So the extension will work but will likely not suggest specific third-party libraries.
- Even if your workspace has detected the proper Python interpreter, the extension still needs its path. And the only way I am aware of how to get it is from the settings.
Differences from Pylance
The extension offers import suggestions only after a
from module import statement is present inside the file, while Pylance is much broader (albeit currently not working for third-party modules).
Also, the suggestion hints are displayed slightly differently.
- There is an output window that I use for debugging.