How to decrease the autocompletion delay in visual studio code for python imported packages?

有些话、适合烂在心里 提交于 2019-12-08 04:24:23

问题


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.

I tried using the following config

"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

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


回答1:


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

Then restart/reload VS Code.

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.

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.

Related:

  • What is the difference between jedi and python language server in VS code IDE?


来源:https://stackoverflow.com/questions/55879999/how-to-decrease-the-autocompletion-delay-in-visual-studio-code-for-python-import

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!