Leon Cruz
Leon Cruz

Reputation: 375

How to make VSCode's autocomplete as powerful as PyCharm?

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.

Upvotes: 5

Views: 6997

Answers (2)

Chiel
Chiel

Reputation: 682

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

Upvotes: 0

Brett Cannon
Brett Cannon

Reputation: 16090

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.

Upvotes: 4

Related Questions