VS Code Pylance 运行缓慢且延迟较多
当我尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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.
接受的答案实际上是一种解决方法。如果您必须打开一个包含许多文件的非常大的目录,例如我用我的代码挂载一个数据目录,那么您可以配置
pyrightconfig.json
以排除数据目录,请参阅 https://github.com/microsoft/pyright/blob/main/docs/configuration.md。顺便说一句,查看输出面板总是有益的,这正是 pylance 建议我做的事情。
然后一切正常!
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.
Then everything works!
尝试将行
"python.analysis.indexing": false,
添加到您的settings.json
中。这将防止 VS Code 尝试预先索引大量文件,从而提高大型项目的性能。Try adding the line
"python.analysis.indexing": false,
to yoursettings.json
. This will prevent vs code from trying to index large numbers of files pre-emptively, which should improve performance on large projects.我尝试了接受的答案,但它没有解决我的问题。
我还对 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.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.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.
将你的工作目录范围缩小一些,它会工作得更顺利。
Scope your working directory to something smaller, it'll work much more smoothly.