64
votes

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?

16
It looks like you are using python 3.7, please could you confirm this? That version is not yet supported by this extension. - vijesh
I am using Python 3.6. - Donovan Keating
Well for me works fine most of the time. But as my file gets larger(at about 500+ lines), it gets really slow, sometimes it might take more than a minute to show suggestions. So I try to keep my views and models small but it's not always possible :( - Vaibhav Vishal
Hi Donovan, did you ever find a solution to your problem? Do you mind sharing it? - Charlie Parker

16 Answers

44
votes

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
11
votes

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.

9
votes

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.

7
votes

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.

6
votes

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
}
5
votes

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.

3
votes

"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

2
votes

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

1
votes

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.

1
votes

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.

1
votes

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.

1
votes

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

Buggy way

import package.module 

Working way

from package import module
1
votes

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.

1
votes

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!

0
votes

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.

-29
votes

For any IDE getting Intellisense for dynamically typed language is not possible.

I see that model is dynamically initialized where IntelliSense can't guess the correct type of the object. For any static typed like C++ or Java, this wouldn't be the case but python is dynamically typed so IntelliSense, not always works as expected.