VS Code Pylance 运行缓慢且延迟较多

发布于 2025-01-10 12:37:08 字数 310 浏览 0 评论 0原文

当我尝试使用 Pylance 使用自动完成功能时,它会卡在那里一段时间

,大约 3 ~ 5 秒后,自动完成功能的弹出窗口会显示

Python Language Server 已设置为 Pylance

到目前为止我已经尝试过的。

重新安装 Python 扩展。

重新安装 VS Code

重新启动 Python 语言服务器

重置 VS Code

重新安装 Pylance。

但以上似乎都不起作用

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

它在我的电脑上运行良好,你如何打开这个 python 文件?

尝试将代码移至其自己的文件夹并打开它,而不是打开某个包含大量文件的大文件夹。这确实显示了一个性能漏洞,即大型工作区需要一段时间才能加载。

您可以参考此页面了解更多详细信息。

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.

夏花。依旧 2025-01-17 12:37:08

接受的答案实际上是一种解决方法。如果您必须打开一个包含许多文件的非常大的目录,例如我用我的代码挂载一个数据目录,那么您可以配置pyrightconfig.json以排除数据目录,请参阅 https://github.com/microsoft/pyright/blob/main/docs/configuration.md

顺便说一句,查看输出面板总是有益的,这正是 pylance 建议我做的事情。

2024-05-02 16:02:53.690 [信息] [错误 - 16:02:53] (62805) 枚举
的工作区源文件花费的时间超过 10 秒。

这可能是因为:

  • 您已将主目录或整个硬盘驱动器作为工作区打开
  • 您的工作区包含大量目录和文件
  • 您的工作区包含指向包含许多文件的目录的符号链接
  • 您的工作区位于远程,文件枚举速度很慢要减少此时间,请打开文件较少的工作区目录或添加一个
    Pyrightconfig.json 配置文件,其中包含“排除”部分
    从工作区中排除子目录。欲了解更多详情,请参阅
    https://github.com/microsoft/pyright/blob/main/文档/configuration.md

然后一切正常!

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!

ゞ记忆︶ㄣ 2025-01-17 12:37:08

尝试将行 "python.analysis.indexing": false, 添加到您的 settings.json 中。这将防止 VS Code 尝试预先索引大量文件,从而提高大型项目的性能。

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.

桃酥萝莉 2025-01-17 12:37:08

我尝试了接受的答案,但它没有解决我的问题。

我还对 VSCode 进行了完全卸载,并删除了其所有扩展,设置,但没有任何改变。 IntelliSense 仍停留在 loading... 上,如下所示。

输入图片这里的描述

唯一对我有用的是安装扩展的另一个版本,直到我找到一个有效的版本(在我的例子中是v2023.9.10)。我检查了几次,更新到最新版本(当前为v2023.10.10)再次导致问题,而安装v2023.9.10修复了它。

输入图片这里的描述

我可能会再试一次,看看他们是否修复了这个错误。与此同时,我将继续与稍早的工作。

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.

上课铃就是安魂曲 2025-01-17 12:37:08

将你的工作目录范围缩小一些,它会工作得更顺利。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文