4

Problem

I love VSCode's look, but it's Python autocomplete is not that satisfactory. For example, when I import numpy and plotly.graph_objects, VSCode can't deduce what's in these modules:

VSCode doesn't know the linspace fuction

VSCode has completely no idea what's in there and lists some nonmembers. Suggestion may vary from time to time.

While PyCharm does a good job with both modules:

PyCharm knows the linspace function

PyCharm lists the members correctly

I remember that VSCode once did as good as PyCharm, but I don't why and how to make VSCode powerful again.


VSCode configurations

Python extension settings:

{
    "python.jediEnabled": false, // I tried both true and false
    "python.analysis.memory.keepLibraryLocalVariables": true,
    "python.analysis.memory.keepLibraryAst": true
}

I waited for the Python extension to fully load and analyze in background. I tried both to enable and disable the Visual Studio IntelliCode extension.

Leon Cruz
  • 345
  • 3
  • 11

2 Answers2

4

If you tried both language servers and VS Code made you reload then you have tried the options currently available to you from the Python extension. We are actively working on making it better, though, and hope to having something to say about it shortly.

But if you can't wait you can try something like https://marketplace.visualstudio.com/items?itemName=ms-pyright.pyright as an alternative language server.

Brett Cannon
  • 14,438
  • 3
  • 45
  • 40
  • 1
    I've already enabled pyright, but the autocompletion still doesn't work for some 3rd party libraries (but I do remember it worked perfectly once, I hope VSCode can do better in the future). Thanks for all your and your team's hard work. It's a little bit harsh to compare VSCode to PyCharm since the latter is a specialized Python IDE. VSCode does a pretty good job on most libraries. – Leon Cruz Jun 10 '20 at 07:52
  • 2
    The comparison is fine. We hope to eventually have better auto-complete than PyCharm. – Brett Cannon Jun 10 '20 at 21:00
0

It might be a problem related to Pylance. By default, Pylance only looks for modules in the root directory. Making some tweaks in the settings made sure everything I import in VSCode works as if it's imported in PyCharm.

Please see:

https://stackoverflow.com/a/67099842/6381389

Chiel
  • 662
  • 1
  • 7
  • 30