Visual Studio Code: Intellisense not working

PythonDjangoVisual Studio-Code

Python Problem Overview


My Visual Studio Code's Intellisense is not working properly. Every time I try to use it with Ctrl + Shift, it only displays a loading message. I'm using Python (with Django) and have installed ms-python.python. I also have Djaneiro. It is still not working. enter image description here

What seems to be the problem here?

Python Solutions


Solution 1 - Python

This can be caused by many reasons, some of them are as follows.

  1. Python executable path in vscode is incorrect

    • Solution: Configure the path to the python executable in settings.json. Remember to restart vscode after.
  2. The module is located in a non-standard location

    • Solution: Configure settings.json to include this location for autocompletion to work. An example (for Linux) used to add a custom module for the workspace:

      {
        "python.pythonPath": "/usr/bin/python",
        "python.autoComplete.extraPaths": [
          "${workspaceFolder}/customModule"
        ]
      }
      
  3. vscode was not launched from the active virtual environment

    • Solution: The path to the modules is set when a virtual environment is activated. Launch vscode from a terminal with the correct virtual environment activated

Solution 2 - Python

Installing Pylance addon caused Vscode Intellisense to stop.
On disabling Pylance and enabling the Default Microsoft Python extension along with Visual Studio IntelliCode(Microsoft) and reverting to the Jedi server(prompted by Vscode) ,restarted intellisense detection.

Solution 3 - Python

If you've tried everything but still if it doesn't work, in my case installing the extension Visual Studio IntelliCode with the Python extension worked.

Solution 4 - Python

First of all if you've installed virtualenv on your project run vscode from there. Then in your vscode settings, i mean settings.json, you can follow my configuration or trace in which one you have a problem. Most of time this problem stem from putting incorrect path in pythonPath setting

    {
  "python.pythonPath": "${workspaceFolder}/env/bin/python3",
  "editor.formatOnSave": true,
  "python.linting.pep8Enabled": true,
  "python.linting.pylintPath": "pylint",
  "python.linting.pylintArgs": ["--load-plugins", "pylint_django"],
  "python.linting.pylintEnabled": true,
  "python.linting.pep8Args": ["--ignore=E501"],
  "files.exclude": {
    "**/*.pyc": true
  }
}

Update:

If you want to have a well-configuration of Vscode That i personally use for developing my Django and React web-applications you can glance this.

Solution 5 - Python

i change change the :jedi true 2 false, or flase 2 true, when reload the VSCode, that's ok.

my setting:

{
    "editor.fontSize": 16,
    "explorer.confirmDragAndDrop": false,
    "extensions.autoUpdate": false,
    "workbench.colorTheme": "Default Dark+",
    "editor.fontFamily": "Consolas, Dengxian",
    "workbench.sideBar.location": "left",
    "workbench.startupEditor": "newUntitledFile",
    "workbench.iconTheme": "material-icon-theme",
    "python.pythonPath": "d:\\Source\\Django\\Scripts\\python.exe",
    "python.linting.pylintEnabled": true,
    "python.linting.enabled": true,
    "git.ignoreLimitWarning": true,
    "python.jediEnabled": true,
    "python.autoComplete.extraPaths": [
        "d:\\Source\\Django\\",
    ],
    "python.autoComplete.addBrackets": true
}

Solution 6 - Python

For me Intellisense stops working randomly when working with Python files.

I just save my files, close the file tab then I re-open and its working again.

Sometimes that doesn't work so I just restart VS code and then Intellisense is back online.

Solution 7 - Python

I had the same problem, but I googled a bit and found this extension: Pylance, which solved the problem.

Solution 8 - Python

"If you find IntelliSense has stopped working, the language service may not be running. Try restarting VS Code and this should solve the issue." From https://code.visualstudio.com/docs/editor/intellisense and helped to me

Solution 9 - Python

In my case , what worked was reinstalling python extension on vscode which auto-install pylance.

then I just hit "ctrl + , " on my keyboard to take me to vscode setting typed: pylance .

clicked on the edit setting.json and change the "python.languageServer" to default

  },
"terminal.integrated.sendKeybindingsToShell": true,
"python.defaultInterpreterPath": "C:source\\env\\Scripts\\python.exe",
"python.disableInstallationCheck": true,
"terminal.integrated.defaultProfile.windows": "Command Prompt",
**"python.languageServer": "Default"**,
"python.analysis.completeFunctionParens": true,
"[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
},
"python.autoComplete.addBrackets": true,
"diffEditor.ignoreTrimWhitespace": false

and I hope this works for you also else you can try reinstall intellicode and python extension then restart your vscode.

I hope you find this useful :)

Solution 10 - Python

My settings were all in order, but still not auto-completing in-line. I disabled the Kite extension & a couple of other ones that I didn't really need, & IntelliSense started auto-completing. Not 100% sure, but I reckon it might have been my "Kite" extension settings that were getting in the way.

Solution 11 - Python

For me, what fixed it was reinstalling the default Python extension and setting the python language server in the seetings to Default.

Steps

  1. Open the commands window by simultaneously pressing CTRL/CMD + Shift + P. Now search for install extensions.
  2. Select Python and install it (uninstall first if already installed).
  • Python is the default Python extension in VSCode and it installs Pylance by default.
  1. Open the commands window again and search this time for Settings. Select Prefernces: Open settings (JSON).
  2. In the JSON file search (CTRL/CMD + F) for python.languageServer and set the value to Default or Pylance as the default is currently Pylance (mine was somehow set to None!).
  3. Once you save the file, a prompt will ask you if you want to reload vscode for the changes to take effect, click Yes!

That's it, intelliSense should be working now using Pylance!

Solution 12 - Python

Just a warning - the original question was asked several years back. Much has changed in that time, including the old MPLS language server being removed, Pylance shipping (but Jedi being the default), and then since mid 2021, Pylance being the default. If you're having issues check the dates on responses before following the advice given; it may be obsolete. The OP's issue is almost certainly one with MPLS which is long gone. If you are having issues with Pylance, consider opening an issue at https://github.com/microsoft/pylance-release.

Solution 13 - Python

I had this issue for a while now. I tried a lot of solutions from stack but none worked. Uninstalling all the extensions did the trick for me.

Solution 14 - Python

I had tried pretty much everything that was listed by others on this page, and none of it worked for me. I was using the Python version from Anaconda.

In the end, the way that I got Python intellisense to start working in VS Code was to:

  1. open up the Terminal (View menu => Terminal)
  2. type conda init powershell
  3. restart VS Code

After that, Python intellisense started working correctly.

Solution 15 - Python

Problem

VSCode Pylance has trouble with pandas.read_csv() and company (pandas.read_pickle(), ...).

Solution

My solution was to call pandas.DataFrame() on the incoming data. This seems to help VSCode Pylance Here's what I had to do:

import pandas as pd

df = pd.read_pickle(
    "path_to_pickle_file.pkl"
)

# Needed to get Pylance Intellisense working
df = pd.DataFrame(df)

Hope this helps someone else. Took me forever to figure it out.

Solution 16 - Python

Assuming you're using Pylance as your language server, what worked for me (based on this conversation) was adding

"python.analysis.extraPaths": [
    "./src/lib"
],

(where .src/lib/ contains your modules and an __init__.py file) to your settings.json.

Note: the setting is called python.analysis.extraPaths and not python.autoComplete.extraPaths!

Solution 17 - Python

I just disabled Pylance in the extensions and suggestions worked again instantly.

Solution 18 - Python

In my case, Pylance was stuck at Loading... since the workspace contained too many files (Large dataset and many log files). Upon inspecting the python language server logs:

Enumeration of workspace source files is taking longer than 10 seconds.

Solution

Add a pyrightconfig.json to your workspace root, and create a list with directories to exclude from the Pylance search (https://github.com/microsoft/pyright/blob/main/docs/configuration.md):

{
  "exclude": [
    "**/data",
    "**/.crash_reports",
    "**/runs",
    "**/wandb",
    "**/notebooks",
    "**/models",
    ".git"
  ]
}

Restart the language server

Solution 19 - Python

I was also facing this problem and it's really annoying. This is a major bug of VS code that happens with installing some of the npm packages. VS code IntelliSense crashes and stops working after a few moments you start the VScode due to unsuccessful loading of the modules of the new package.

In my case, it was solved by using the VScode insiders version: https://code.visualstudio.com/insiders/

Download and install VScode insiders, install all the extension you use and then check if the problem is fixed.

Solution 20 - Python

In my case, I fix the Intellisense by changing import code.

Buggy way

import package.module 

Working way

from package import module

Solution 21 - Python

In my case there was a problem with the python language server after a vs code update. The download of the language server was stuck every time. See enter link description here What I had to do was to open settings and type "languge server ". Then there are a few options like css, html etc. ( whatever you might have installed )

Select Python and search for lanuge server. Also if it is mentioned that the default is pylance, I had to switch it to Pylance and restart the ide ( update the window )

After this action my intellysense worked again.

Solution 22 - Python

What worked for me was to uninstall the Python extension & restart VS Code. IntelliSense sprang to life! This may not make sense as I left the extension uninstalled. Your comments are welcome!

Solution 23 - Python

go to Extensions (Ctrl+Shift+X). you should have installed following extensions: python extensions

*:Note: some of them may needs to be restarted, in this way it is shown in the right side of extension.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDonovan KeatingView Question on Stackoverflow
Solution 1 - PythonJerinView Answer on Stackoverflow
Solution 2 - PythonstarzarView Answer on Stackoverflow
Solution 3 - Pythonc-shubhView Answer on Stackoverflow
Solution 4 - PythonEhsan AhmadiView Answer on Stackoverflow
Solution 5 - Pythonrogers.wangView Answer on Stackoverflow
Solution 6 - PythonGIVE-ME-CHICKENView Answer on Stackoverflow
Solution 7 - PythonDYSLEVIUMView Answer on Stackoverflow
Solution 8 - PythonViktor PoliushkoView Answer on Stackoverflow
Solution 9 - PythonAdetoye AnointingView Answer on Stackoverflow
Solution 10 - PythonMacdara.DevView Answer on Stackoverflow
Solution 11 - PythonKarim SonbolView Answer on Stackoverflow
Solution 12 - PythonGraham WheelerView Answer on Stackoverflow
Solution 13 - PythonV ReddyView Answer on Stackoverflow
Solution 14 - PythonRon BertinoView Answer on Stackoverflow
Solution 15 - PythonMatt DanchoView Answer on Stackoverflow
Solution 16 - PythonTomasz BartkowiakView Answer on Stackoverflow
Solution 17 - PythonsmcsView Answer on Stackoverflow
Solution 18 - PythonhingeView Answer on Stackoverflow
Solution 19 - PythonalshafiView Answer on Stackoverflow
Solution 20 - PythonPomodoroView Answer on Stackoverflow
Solution 21 - PythonFishingIsLifeView Answer on Stackoverflow
Solution 22 - PythonDavid TarbillView Answer on Stackoverflow
Solution 23 - PythonAli Akbar KiaeiView Answer on Stackoverflow