【发布时间】:2021-08-10 20:18:56
【问题描述】:
OS = Ubuntu 18.04 64 bit LTS
VSCode version = 1.59.0
在以下代码中的“
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
window = Gtk.Window(title="Hello World")
window.??? <<<<<<<< HERE
window.show()
window.connect("destroy", Gtk.main_quit)
if __name__ == "__main__":
Gtk.main()
我在 VSCode 终端的虚拟环境中使用 pip3 安装了以下软件包:
pip3 install Pycairo
pip3 install PyGObject
pip3 install SQLAlchemy==1.4.22
pip3 install psutil
pip3 install pexpect
pip3 install websockets
pip3 install PyGobject PGObject-stubs
安装 PyGobject PGObject-stubs 后,我可以在 window. 之后看到以下内容:
window.__new__
window.__annotations__
window.__class__
window.__delattr__
和其他 "__xxx__" 选项,但没有常规选项,如连接、显示、添加、调整大小等。
这是我在 .vscode 目录下的 settings.json 代码:
{
"python.defaultInterpreterPath": "/usr/bin/python3.9",
"python.linting.enabled": false,
"python.linting.pylintPath": "pylint",
"editor.formatOnSave": true,
"python.formatting.provider": "yapf", // or "black" here
"python.linting.pylintEnabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.python"
}
}
我必须怎么做才能让 VSCode 识别 PyGOject 库的自动完成功能?
【问题讨论】:
-
你在虚拟环境中选择了解释器吗?调出命令面板 (Ctrl-Shift-P) 并开始输入“Python: Select Interpreter”,然后确保您使用的是虚拟环境的 Python 解释器。
标签: visual-studio-code ubuntu-18.04 pygobject