VS Code Pylance works slow with much delay
Asked Answered
H

5

14

When I try to use the autocomplete using Pylance it is stuck there for some time

and After Some time like 3 ~ 5 seconds the pop up with auto-complete shows up

Python Language Server is already set to Pylance

What I've tried so far.

Reinstall Python Extension.

Reinstall VS Code

Restarted Python Language Server

Reset VS Code

Reinstall Pylance.

But None of the above seems to work

Harquebus answered 28/2, 2022 at 5:28 Comment(3)
You can find tons of similar reports github.com/microsoft/pylance-release/issues so be patient.Nakesha
Could you attach the codes instead of the picture? That will be helpful to test locally.Benzedrine
@Benzedrine Added the codes for this issue..Harquebus
B
3

It works well on my computer, how do you open this python file?

Try moving your code to its own folder and opening that up instead of opening up some big folder that contains a lot of files. This does show a performance hole where large workspaces take a while to load.

You can refer to this page for more details.

Benzedrine answered 1/3, 2022 at 9:1 Comment(1)
my workspace also contained the virtualenv and seems like it was causing the issue.. now after opening the folder directly solved it!!!! Thanks..Harquebus
K
2

Try adding the line "python.analysis.indexing": false, to your settings.json. This will prevent vs code from trying to index large numbers of files pre-emptively, which should improve performance on large projects.

Kalikalian answered 9/5, 2024 at 11:11 Comment(0)
V
0

I tried the accepted answer, but it didn't solve my problem.

I also did a complete uninstall of VSCode and removed all its extensions and settings, but nothing changed. The IntelliSense was still stuck on loading... as shown below.

enter image description here

The only thing that worked for me was to Install another version of the extension, until I found one that worked (in my case v2023.9.10). I checked several times that updating to the latest version (currently v2023.10.10) caused the problem again, while installing v2023.9.10 fixed it.

enter image description here

I may try again in a while to see whether they fix the bug. In the meantime I will keep working with the slightly earlier.

Vitellin answered 8/10, 2023 at 10:15 Comment(0)
S
0

Scope your working directory to something smaller, it'll work much more smoothly.

Silurid answered 4/3, 2024 at 3:34 Comment(1)
Please share more details about how to do this. A good explanation helps others to learn from your answerGift
A
0

The accepted answer is actually a workaround. If you have to open a very big directory which contains many files, e.g. I mount a data directory with my codes, then you can configure pyrightconfig.json to exclude the data dir, see https://github.com/microsoft/pyright/blob/main/docs/configuration.md.

BTW, it's always beneficial to take a look at the output panel, this is exactly what pylance advises me to do.

2024-05-02 16:02:53.690 [info] [Error - 16:02:53] (62805) Enumeration of workspace source files is taking longer than 10 seconds.

This may be because:

  • You have opened your home directory or entire hard drive as a workspace
  • Your workspace contains a very large number of directories and files
  • Your workspace contains a symlink to a directory with many files
  • Your workspace is remote, and file enumeration is slow To reduce this time, open a workspace directory with fewer files or add a pyrightconfig.json configuration file with an "exclude" section to exclude subdirectories from your workspace. For more details, refer to https://github.com/microsoft/pyright/blob/main/docs/configuration.md.

Then everything works!

Apc answered 2/5, 2024 at 14:14 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.