【问题标题】:VS code displays "Problems" when there are noneVS 代码在没有时显示“问题”
【发布时间】:2018-06-13 04:17:08
【问题描述】:

我开始使用 VS Code,但我正试图找出一个问题:

我有一个非常小的基本代码:

from PySide import QtGui, QtCore
app = QtGui.QApplication([])
window = QtGui.QWidget()
window.show()
app.exec_()

第一次启动时,我忘记了QApplication 构造函数中的[] 参数,因此实际上出现了错误。我现在已经更正了,我可以启动应用程序,窗口正常显示,一切正常。

但是,VS Code 继续向我显示 2 个错误:

{
    "resource": "/f:/Dev/python-ui/firstApp.py",
    "owner": "python",
    "code": "E1101",
    "severity": 8,
    "message": "E1101:Module 'PySide.QtGui' has no 'QApplication' member",
    "source": "pylint",
    "startLineNumber": 4,
    "startColumn": 7,
    "endLineNumber": 4,
    "endColumn": 7
}

{
    "resource": "/f:/Dev/python-ui/firstApp.py",
    "owner": "python",
    "code": "E1101",
    "severity": 8,
    "message": "E1101:Module 'PySide.QtGui' has no 'QWidget' member",
    "source": "pylint",
    "startLineNumber": 5,
    "startColumn": 10,
    "endLineNumber": 5,
    "endColumn": 10
}

我错过了什么?

这很烦人,因为在文件列表中我的名称是红色的。

【问题讨论】:

    标签: python visual-studio-code pylint


    【解决方案1】:

    这意味着您选择运行的 linter 无法在对象上找到这些属性。确保 PySide 安装在您为 VS Code 选择的环境中,并且 linter 能够找到该包。

    【讨论】:

    • 但是当我按下 F5 时,应用程序启动并且我看到 PySide 窗口,这意味着 PySide 已正确安装,对吧?我没有为自己安装任何“linter”,我猜它确实是随 python 包或直接与 VS Code 一起提供的
    • VS Code 不附带 linter,但它会提示您安装 PyLint。但如果它正在执行,那么它只是意味着 PyLint 无法解析该属性。
    • 不管怎样,那我该怎么办?
    • 也许向 PyLint 提出问题?
    • 那么,你认为这是一件大事,而不是我做错了什么?我会觉得这很奇怪,不是吗?
    猜你喜欢
    • 1970-01-01
    • 2019-09-19
    • 2012-08-08
    • 1970-01-01
    • 2018-04-16
    • 1970-01-01
    • 2018-12-02
    • 2021-08-11
    • 1970-01-01
    相关资源
    最近更新 更多