Ferus
Ferus

Reputation: 1118

VS Code: Analyzing in the background

When I start a python project in vs code (with the microsoft python extension) it starts "Analyzing in the background" and python keep crashing. It also uses a ton of memory.enter image description here

Anyone knows how to fix this? Or is it supposed to do this?

Upvotes: 29

Views: 26561

Answers (6)

I had this problem recently and after trying many solutions, what worked for me was a combination of

"python.analysis.exclude": [
        "**/site-packages/**",
        "**/data/**"
    ],

and

"files.watcherExclude": {
        "**/.git/objects/**": true,
        "**/.git/subtree-cache/**": true,
        "**/node_modules/*/**": true,
        "**data": true,
    },

Not sure which of the two was required, but finally my laptop stopped hyperventilating for no reason. In case it is useful to anyone

Upvotes: 0

Vince Cole
Vince Cole

Reputation: 1

Here is how I solved this issue:

Go to File > Preferences > Settings > TYPE "python.language server"

If set to 'Microsoft' change your language server to 'Pylance'

Python: Language Server
Define Type of the Language Server
SELECT: Pylance

Reload your Visual Studio Code Try importing your libraries causing the issues again:

import numpy as np
import pandas as pd

Upvotes: 0

Cleb
Cleb

Reputation: 25997

I had the same issue; the only solution that worked for me was to open settings.json (ctrl + Shift + P) and change

"python.languageServer": "Microsoft"

to

"python.languageServer": "Pylance"

Then one gets a pop-up that asks whether one wants to reload the window which one should confirm by pressing "OK".

Then everything works normally again (IntelliJ, autocomplete etc).

As @Vasco pointed out in the comments Microsoft is no longer supported as explained in this thread.

Upvotes: 12

Yuri Feldman
Yuri Feldman

Reputation: 2584

Can solve this by either disabling the extension as suggested in previous answers, or excluding large directories (e.g. containing data) from its search path, by adding to your workspace settings an python.workspaceSymbols.exclusionPatterns key, like so:

settings.json:

{
    "python.workspaceSymbols.exclusionPatterns": [
        "**/site-packages/**",
        "your_pattern_or_directory_to_exclude"
    ]
}

See also the vscode extension docs.

Upvotes: 4

neo lei
neo lei

Reputation: 101

High memory usage: https://github.com/Microsoft/python-language-server/issues/832 Jedi is an autocompletion tool for Python that can be used in IDEs/editors. Jedi works. Jedi is fast. It understands all of the basic Python syntax elements including many builtin functions. So you can switch Jedi instead of Python Language Server.

Process:

  1. set "python.jediEnabled": true

  2. disable the Visual Studio IntelliCode plugin

  3. delete the .vscode directory

Upvotes: 9

KMFR
KMFR

Reputation: 935

This seems to have fixed it for me: https://github.com/Microsoft/vscode-python/issues/4990#issuecomment-477628947

You can disable the new Python Language Server by opening settings in VSCode (Ctrl+, ) and set "python.jediEnabled": true. Then reload the window and/or restart VSCode.

Upvotes: 28

Related Questions