Visual Studio Code Python Intellisense



  • Increase the power of Visual Studio Code through Extensions. For example ms-python.python. Example: code -extensions-dir Set the root path for extensions. Code -list-extensions List the installed extensions. Code -show-versions Show. Tags may contain any string and are not provided by IntelliSense, so review the Marketplace to.
  • Jinja template language support for Visual Studio Code; More Details Conclusion. The 21 top Vscode Python extensions discussed in this article will help you a lot when working on a project. These Vscode Python Extensions will make your time on visual studio code a memorable one as you develop mobile applications with python.
  • Python is an interpreted language, and in order to run Python code and get Python IntelliSense, you must tell VS Code which interpreter to use. From within VS Code, select a Python 3 interpreter by opening the Command Palette (Ctrl+Shift+P), start typing the Python: Select Interpreter command to search, then select the command.

Keep your code consistent easily with Visual Studio IntelliCode, which dynamically creates an.editorconfig file from your codebase to define coding styles and formats. Note: All Preview features are off by default and can be enabled through the Tools Options IntelliCode page. Visual Studio Code is highly extensible and customizable. Take a look at some of the extensions that make Python development in VSCode a better experience. Python by Microsoft.

-->

Vscode Python Intellisense Stops Working

To view Python options, use the Tools > Options menu command, make sure Show all settings is selected, and then navigate to Python:

There are also additional Python-specific options on the Text Editor > Python > Advanced tab, and on the Environment > Fonts and Colors tab within the Text Editor group.

Note

The Experimental group contains options for features that are still under development and are not documented here. They are often discussed in posts on the Python engineering at Microsoft blog.

General options

(Tools > Options > Python tab.)

OptionDefaultDescription
Show the Output Window when creating virtual environmentsOnClear to prevent the Output window from appearing.
Show the Output Window when installing or removing packagesOnClear to prevent the Output window from appearing.
Show notifications bar to create environmentsOnVisual Studio 2019 only. When this option is set and the user opens a project that contains a requirements.txt or environment.yml file, Visual Studio displays an information bar with suggestions to create a virtual environment or conda environment, respectively, instead of using the default global environment.
Show notifications bar to install packagesOnVisual Studio 2019 only. When this option is set and the user opens a project that contains a requirements.txt file (and is not using the default global environment) Visual Studio compares those requirements with packages installed in the current environment. If any packages are missing, Visual Studio displays a prompt to install those dependencies.
Always run package managers as administratorOffAlways elevates pip install and similar package manager operations for all environments. When installing packages, Visual Studio prompts for administrator privileges if the environment is located in a protected area of the file system such as c:Program Files. In that prompt you can choose to always elevate the install command for just that one environment. See Packages tab.
Automatically generate completion DB on first useOnApplies to Visual Studio 2017 version 15.5 and earlier and to later versions when using an IntelliSense database. Prioritizes completion of the database for a library when you write code that uses it. For more information, see Intellisense tab.
Ignore system-wide PYTHONPATH variablesOnPYTHONPATH is ignored by default because Visual Studio provides a more direct means to specify search paths in environments and projects. See Search paths for details.
Update search paths when adding linked filesOnWhen set, adding a linked file to a project updates Search paths so that IntelliSense can include the contents of the linked file's folder in its completion database. Clear this option to exclude such content from the completion database.
Warn when imported module cannot be foundOnClear this option to suppress warnings when you know an imported module isn't presently available but doesn't otherwise affect code operation.
Report inconsistent indentation asWarningsBecause the Python interpreter depends heavily on proper indentation to determine scope, Visual Studio by default issues warnings when it detects inconsistent indentations that might indicate coding errors. Set to Errors to be even more strict, which causes the program to exit in such cases. To disable this behavior altogether, select Don't.
Check for survey/newsOnce a weekVisual Studio 2017 and earlier. Sets the frequency at which you allow Visual Studio to open a window containing a web page with Python-related surveys and news items, if available. Options are Never, Once a day, Once a week, and Once a month.
Reset all permanently hidden dialogs buttonn/aDifferent dialog boxes provide options such as Don't show me this again. Use this button to clear those options and cause the dialogs to reappear.

Conda options

(Tools > Options > Python > Conda tab.)

OptionDefaultDescription
Conda executable path(blank)Specifies an exact path to the conda.exe executable rather than relying on the default Miniconda installation that's included with the Python workload. If another path is given here, it takes precedence over the default installation and any other conda.exe executables specified in the registry. You might change this setting if you manually install a newer version of Anaconda or Miniconda, or want to use a 32-bit distro rather than the default 64-bit distro.

Debugging options

(Tools > Options > Python > Debugging tab.)

OptionDefaultDescription
Prompt before running when errors are presentOnWhen set, prompts you to confirm that you want to run code that contains errors. Clear this option to disable the warning.
Wait for input when process exits abnormally
Wait for input when process exits normally
On (for both)A Python program started from Visual Studio runs in its own console window. By default, the window waits for you to press a key before closing it regardless of how the program exits. To remove that prompt and close the window automatically, clear either or both of these options.
Tee program output to Debug Output windowOnDisplays program output in both a separate console window and the Visual Studio Output window. Clear this option to show output only in the separate console window.
Break on SystemExit exception with exit code of zeroOffIf set, stops the debugger on this exception. When clear, the debugger exits without breaking.
Enable debugging of the Python standard libraryOffMakes it possible to step into the standard library source code while debugging, but increases the time it takes for the debugger to start.
Show function return valueOnVisual Studio 2019 only. Displays function return values in the Locals window then stepping over a function call in the debugger (F10)
Use legacy debuggerOffVisual Studio 2019 only. Instructs Visual Studio to use the legacy debugger by default. For more information, see Debugging - Use the legacy debugger.

Diagnostics options

(Tools > Options > Python > Diagnostics tab.)

OptionDefaultDescription
Include analysis logsOnIncludes detailed logs relating to analysis of installed Python environments when saving diagnostics to a file or copying them to the clipboard using the buttons. This option may significantly increase the size of the generated file, but is often required to diagnose IntelliSense issues.
Save diagnostics to file buttonn/aPrompts for a filename, then saves the log to a text file.
Copy diagnostics to clipboard buttonn/aPlaces the entirety of the log on the clipboard; this operation may take some time depending on the size of the log.

Interactive Windows options

Visual Studio Code Python Intellisense Not Working

(Tools > Options > Python > Interactive Windows tab.)

OptionDefaultDescription
Scriptsn/aSpecifies a general folder for startup scripts to apply to Interactive windows for all environments. See Startup scripts. Note, however, that this feature does not currently work.
Up/down arrows navigate historyOnUses the arrow keys to navigate through history in the Interactive window. Clear this setting to use the arrow keys to navigate within the Interactive window's output instead.
Completion modeOnly evaluate expressions without function callsThe process of determining the available members on an expression in the Interactive window may require evaluating the current unfinished expression, which can result in side-effects or functions being called multiple times. The default setting, Only evaluate expressions without function calls excludes expressions that appear to call a function, but evaluates other expressions. For example, it evaluates a.b but not a().b. Never evaluate expressions prevents all side-effects, using only the normal IntelliSense engine for suggestions. Evaluate all expressions evaluates the complete expression to obtain suggestions, regardless of side effects.
Hide static analysis suggestionsOffWhen set, displays only suggestions that are obtained by evaluating the expression. If combined with the Completion mode value Never evaluate expressions, no useful completions appear in the Interactive window.

Language server options

(Tools > Options > Python > Language server tab.)

OptionDefaultDescription
Disable completions from TypeshedOffVisual Studio IntelliSense normally uses a bundled version of Typeshed (a set of .pyi files) to find type hints for standard library and third-party libraries for both Python 2 and Python 3. Setting this option disables the bundled TypeShed behavior.
Custom Typeshed path(blank)If set, Visual Studio uses the Typeshed files at this path instead of its bundled version. Ignore if Disable completions from Typeshed is set.

Advanced Python editor options

(Tools > Options > Text Editor > Python > Advanced tab.)

Completion Results

OptionDefaultDescription
Member completion displays intersection of membersOffWhen set, shows only completions that are supported by all possible types.
Filter list based on search stringOnApplies filtering of completion suggestions as you type (default is checked).
Automatically show completions for all identifiersOnClear this option to disable completions in both the editor and Interactive windows.

Selection in Completion List

OptionDefaultDescription
Committed by typing the following characters{}[]().,:;+-*/%&|^~=<>#@These characters typically follow an identifier that one might select from a completion list, so it's convenient to commit the completion simply by typing a character. You can remove or add specific characters to the list as desired.
Enter commits current completionOnWhen set, the Enter key chooses and applies the currently selected completion as with the characters above (but of course, there isn't a character for Enter so it couldn't go into that list directly!).
Add new line on enter at end of fully typed wordOffBy default, if you type the entire word that appears in the completion popup and press Enter, you commit that completion. By setting this option, you effectively commit completions when you finish typing the identifier, such that Enter inserts a new line.

Miscellaneous Options

OptionDefaultDescription
Enter outlining mode when files openOnAutomatically turn on Visual Studio's outlining feature in the editor when opening a Python code file.
Paste removed REPL promptsOnRemoves >>> and ... from pasted text, allowing easy transfer of code from the Interactive window to the editor. Clear this option if you need to retain those characters when pasting from other sources.
Color names based on typesOnEnables syntax coloring in Python code.

Fonts and Colors options

(Environment > Fonts and Colors tab within the Text Editor group.)

The names of the Python options are all prefixed with Python and are self-explanatory. The default font for all Visual Studio color themes is 10 pt Consolas regular (not bold). The default colors vary by theme. Typically, you change a font or color if you find it difficult to read text with the default settings.

Today my colleague, Dmitry Efremov, got an issue after installing the latest VSCode and Python extension - intellisense plainly stopped working for all packages except few very basic.

Visual Studio Code Python Intellisense Path

After enabling logging for the extension ('python.devOptions': ['DEBUG'] in user settings), it turned out that jedi, tool used for intellisense, fails with the next message in the output:
---------------------------
stderr jediProxy
Error (stderr) Traceback (most recent call last):
File 'completion.py', line 313, in watch
self._process_request(self._input.readline())
File 'completion.py', line 294, in _process_request
script.goto_assignments(), request['id']))
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/api/__init__.py', line 382, in goto_assignments
results = self._goto()
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/api/__init__.py', line 438, in _goto
definitions = self._evaluator.goto(name)
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/evaluate/__init__.py', line 354, in goto
modules = imports.ImportWrapper(self, name).follow(is_goto=True)
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/evaluate/cache.py', line 41, in wrapper
rv = function(obj, args, *kwargs)
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/evaluate/imports.py', line 94, in follow
types = importer.follow()
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/evaluate/cache.py', line 41, in wrapper
rv = function(obj, args, *kwargs)
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/evaluate/imports.py', line 252, in follow
return self._do_import(self.import_path, self.sys_path_with_modifications())
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/evaluate/imports.py', line 281, in _do_import
bases = self._do_import(import_path[:-1], sys_path)
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/evaluate/imports.py', line 347, in _do_import
module = _load_module(self._evaluator, module_path, source, sys_path)
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/evaluate/imports.py', line 449, in _load_module
cached = cache.load_parser(path)
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/cache.py', line 210, in load_parser
return ParserPickling.load_parser(path, p_time)
File '/home/dmitry/.vscode/extensions/donjayamanne.python-0.3.17/pythonFiles/jedi/cache.py', line 267, in load_parser
parser_cache_item = pickle.load(f)
AttributeError: 'module' object has no attribute 'ParserWithRecovery'

After modifying onjayamanne.python-0.3.17/pythonFiles/jedi/cache.py to print some debug info, it turned out that the problem was in the cache which the newer version of extension or jedi did not properly clean up.
So the solution turned out to be to clear the cache:Visual studio code python intellisense path
rm -rf ~/.cache
Solved!