Auto-import suggestions for modules already imported in Visual Studio Code.
NOTE: They have added back this feature to one of latests version of Pylance, so you can uninstall this extension if you are using Pylance.
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.
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
pythonAutoImport.python
. - Using the vscode configuration
python.defaultInterpreterPath
.
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 OS basepython
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.
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.