python visual studio 包管理_如何减少python导入包的Visual Studio代码中的自动完成延迟?...

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:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值