Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code: Intellisense not working

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?

like image 651
Donovan Keating Avatar asked May 17 '18 11:05

Donovan Keating


People also ask

Why is IntelliSense not working Visual Studio code?

If you're coding in JavaScript or TypeScript and finds that VSCode IntelliSense does work but does not behave properly, it's likely that you've selected the wrong language mode. TypeScript and JavaScript share the same language service, so you need to select the right language.

How do I enable IntelliSense code in Visual Studio?

You can trigger IntelliSense in any editor window by typing Ctrl+Space or by typing a trigger character such as the . (dot character).

How do I restart IntelliSense?

For Visual Studio 2017 (and I think Visual Studio 2019 also), close Visual Studio, go into the . vs folder in your projects folder and delete all the contents apart from the . suo file, then reopen Visual Studio. This way you can rebuild the Intellisense cache without losing your preferences.


4 Answers

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
like image 127
Jerin Avatar answered Oct 17 '22 16:10

Jerin


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.

like image 21
starzar Avatar answered Oct 17 '22 18:10

starzar


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.

like image 14
c-shubh Avatar answered Oct 17 '22 17:10

c-shubh


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.

like image 9
Ehsan Ahmadi Avatar answered Oct 17 '22 17:10

Ehsan Ahmadi