如何减少python导入包的Visual Studio代码中的自动补全延迟? [英] How to decrease the autocompletion delay in visual studio code for python imported packages?

查看:298
本文介绍了如何减少python导入包的Visual Studio代码中的自动补全延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用python 3.7.3和visual studio代码1.33.1.当我导入任何库(例如cv2或numpy)并尝试使用它时,自动补全功能需要4到5秒钟来识别功能.当我使用诸如print(),slice()等默认函数时,它们会在1秒钟内自动完成.

I am using python 3.7.3 and visual studio code 1.33.1. When I import any library like cv2 or numpy and try to use it, the autocompletion takes 4-5 seconds to identify the functions. When I use the default functions like print(),slice(), etc., they autocomplete within 1 second.

我尝试使用以下配置

"python.linting.pylintArgs": ["--extension-pkg-whitelist=cv2"],
"python.autoComplete.extraPaths": [
    "C:\Users\Pratik\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\cv2"
]

import cv2
import numpy
cv2.   #here I need to list all functions

我希望将自动完成延迟从4-5秒减少到1s.

I expect to decrease the autocompletion delay from 4-5 seconds to 1s.

推荐答案

除了python.autoComplete.extraPaths,尝试设置

In addition to python.autoComplete.extraPaths, try setting the jediEnabled setting to false, to enable the Microsoft Python Language Server (which is disabled by default):

"python.jediEnabled": false

然后重新启动/重新加载VS代码.

Then restart/reload VS Code.

重新加载窗口后,打开输出"选项卡,然后单击您的Python文件.您应该看到显示"正在启动Microsoft Python语言服务器."消息(从右上角的下拉列表中选择 Python 来查看它).底部状态栏上还应该显示"正在后台分析... "消息.

When the window is reloaded, open the Output tab then click on your Python file. You should see a "Starting Microsoft Python language server." message displayed (select Python from the top-right dropdown to see it). There should also be an "Analyzing in background..." message at the bottom status bar.

等待" Analyzing .. "消息消失(表示已完成).如果您是第一次启用此功能,则需要一段时间才能下载.另外,检查输出日志,确认语言服务器正在搜索正确的 site-packages 路径(添加到python.autoComplete.extraPaths的路径应出现在"配置搜索路径"中).

Wait for the "Analyzing.." message to disappear (meaning it's finished). If you're enabling this for the first time, it takes a while to download. Also, check the output logs that the language server is searching the correct site-packages paths (paths added to python.autoComplete.extraPaths should appear in the "Configuration Search Paths").

现在,自动完成/智能提示应该要快得多.

The autocomplete/intellisense should be much faster now.

相关:

这篇关于如何减少python导入包的Visual Studio代码中的自动补全延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆