简体   繁体   中英

Python in VS Code: Auto-completion (IntelliSense) not working for object instances in the editor tab

I'm new to Python and I'm trying to use VS Code as IDE, and it's IntelliSense (auto-completion) to improve the development.

But I find that the IntelliSense is not working for object instances in the Editor Tab .

I have the example on the figure below, where I created a figure and tried to access its properties via IntelliSense on the editor tab: the properties are not available, only variables.

What is curious is that: on the Python Interactive Tab, the IntelliSense (autocomplete) works fine, for the same object. This example is in the same figure below.

I've tried to disable the Jedi IntelliSense, but it didn't change anything.

在此处输入图片说明

The code used in the image is as follows

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0,10,1000)
y = np.cos(x)

fig,ax = plt.subplots()
ax.plot(x,y)

The reason it works in the interactive window is it is working against live data, and so Python itself can say what things should be. But in the editor windows it's all inferred via IntelliSense which is much harder to get right. If you tried both Jedi and MPLS as IntelliSense engines and neither work then I'm afraid there isn't much to do until one of them improves enough to work in that specific situation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM