28

I've been using Visual Studio Community for a few months now, but the sluggishness and project-based interface is not to my liking and having seen that Visual Studio Code has a python extension, I decided to try Code again.

There are two problems with Code, that if possible to solve I'd promote it to my main editor.

First is intellisense. I have downloaded the python extension for Code, which promises intellisense. However, outside of the core python packages (like "math") intellisense is not working. I've tried to set up the extra environment variable as described in the link, but that didn't work either.

After this I re-crated an anaconda environment, just in case. Each anaconda environment basically operates as a separate python install and has the modules like "scipy" etc under Lib/site-packages to properly be able to reference them.

As you might guess, intellisense for VS Code still isn't working. Maybe there's a way to refresh its database like for VS Community but I couldn't find it.

My second issue is lack of auto-indentation for python, which wasn't the case when I first installed Code some 6 months ago. The issue was present 2-3 months ago, I hoped it was fixed by now but apparently not. There's nothing new written about it on the Internets either.

How do I get VS Code to work well for me with python?

Gama11
  • 31,714
  • 9
  • 78
  • 100
Erol Can Akbaba
  • 387
  • 1
  • 4
  • 7
  • 8
    Hi, I'm the author of the Python extension for VS Code. Auto indenting has been fixed in the latest version of the extension. I will have a look at the intellisense for modules such as math in Anaconda - an issue has been raised for this on GitHub https://github.com/DonJayamanne/pythonVSCode/issues/169 – Don Jun 17 '16 at 07:02
  • 1
    Tried it and auto-indenting indeed works. But, `matplotlib.` gives no suggestions. `import matplotlib.pyplot as plt` also gives no suggestions, and the tooltip gets stuck at "Loading..." – Erol Can Akbaba Jun 22 '16 at 10:23
  • Hi Erol, a new update has been pushed through please let me know how it goes. If possible I'd like to move this conversation to the github issues regiser (https://github.com/DonJayamanne/pythonVSCode/issues/169). – Don Jun 23 '16 at 08:16

7 Answers7

34

I have installed python 3.6.5 and Django 2.0.4 on windows 10 OS.

In vs code open command palette (Ctrl+Shift+p).

There select Python:Select Interpreter

Close your vs code and then try. If it still does not work. Try again by changing to:-

Python:Build Workspace symbols and re-open the vs code. That's all i did and got intelligence enabled.

Shashikant Pandit
  • 2,752
  • 22
  • 29
  • 7
    I am getting the following error ... Command 'Python: Build Workspace Symbols' resulted in an error (command 'python.buildWorkspaceSymbols' not found) – Anshul Nov 11 '20 at 05:20
5

Old question that worth another working answer:

In settings.json, set the value of python.jediEnabled to false (see some more details here).

P.S. You can also try and move back to Jedi (just remove python.jediEnabled or set it to true), and in my case, Intellisense keeps working, though much slower.

OfirD
  • 9,442
  • 5
  • 47
  • 90
2

This is how I got Python intellisense to start working in VS Code:

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

After that, Python intellisense started working correctly for me.

Ron Bertino
  • 141
  • 1
  • 7
2

On your VS code use the command ctr + shift + P then search for Python: Select Lint and choose your preferred linting tool. This worked for me.

1

Bro, instead of

import matplotlib.pyplot as plt

Try:

from matplotlib import pyplot as plt

I've tried it in VSCode and it works for the second statement but not the first statement.

Wong Jia Hau
  • 2,639
  • 2
  • 18
  • 30
1

This is how I got it to work:

  1. Open command palette (Ctrl + Shift + P).

  2. Type "Python: Build Workspace Symbols" and hit Enter.

  3. Done.

Neil
  • 1,275
  • 11
  • 25
0

step 1: go to your environment directory of your anaconda and navigate to :

/lib/python*.*/site-packages : this is where all your enviornment package are installed

step 2: copy the complete path upto site-package

step 3: open settings.json file in vscode

step 4: add the following key-value pair

python.analysis.extraPaths": [
            "full/path/upto/site-packages",
"any/other/path/you/want/to/consider"
        ]
Prason Ghimire
  • 403
  • 4
  • 4