Python auto-import extension for VSCode
Is there a Python auto-import extension/plugin available for VSCode?
By auto-import I mean automatically importing of Python modules, so if you type sys.argv then it should automatically import the...
https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196
Stack Overflow
(Updated answer as of August 2023)

These did it for me:

"python.analysis.indexing": true, "python.analysis.autoImportCompletions": true,

If that is slowing down your computer too much because it's indexing too many files, then look into specifying patterns and depths of directories to include in the indexing using "python.analysis.packageIndexDepths", or using "python.analysis.exclude".

Note that I am using Pylance (currently the default, as of January 2023).

Check out the VSCode python settings reference for more info on each of those settings.

Edit August 2023: removed "python.analysis.autoImportUserSymbols" because @YellowStrawHatter pointed out that no longer exists.

No, but it will soon be a part of vscode-python: https://github.com/Microsoft/vscode-python/pull/636

EDIT: See answer by @Eric, who built such an extension.

EDIT 2: See answer by @Eyal Levin, mentioning such an extension (Pylance).

From https://github.com/microsoft/python-language-server/issues/19#issuecomment-587303061:

For those who wonder how to trigger auto-importing as I did, here are the steps.

Enable Microsoft Python Language Server by removing the check of Python: Jedi Enabled in your settings.

Reload the VSCode window.

Hover your mouse over the variable that you want to import, and click Quick fix...

For the last step, if it shows No quick fixes available or Checking for quick fixes, you may need to wait for a while until the extension has finished code analysis. It is also possible to set a shortcut that triggers a quick fix.

You can set the setting(true) below to settings.json for auto import. *Pylance extension installed automatically when Python extension is installed has the setting(true) below which is false by default and you can see my answer explaning how to open settings.json:

// "settings.json" { ... "python.analysis.autoImportCompletions": true }

Then, it shows all matched attributes and modules as shown below:

Then, pressing Enter can automatically import what you select as shown below:

In addition, if you don't set the setting(true) below to settings.json for auto import:

// "settings.json" { ... // "python.analysis.autoImportCompletions": true }

Then, it only shows below: