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.
解决方案
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: