-1

My problem is after installing Python and PyQt5 in vs code, when I run the code he show me this problem:

enter image description here

Undefined variable 'QApplication'
Undefined variable 'QDialog'

But I found a solution here No name 'QApplication' in module 'PyQt5.QtWidgets' error in Pylint which is by adding "python.linting.pylintArgs": ["--extension-pkg-whitelist=PyQt5"] in settings.json.

enter image description here

( I also try to put a comma at the last line "python.linting.pylintArgs": ["--extension-pkg-whitelist=PyQt5,"] but it doesn't work)

It solves the first problem and the code is working in a window, but it also create another big problem:

enter image description here

What should I do to solve my issue?

Thân LƯƠNG Đình
  • 3,082
  • 2
  • 11
  • 21
Hamid MM
  • 9
  • 3

1 Answers1

0

Since the warning here comes from pylint, and it does not affect the execution of the code, we can turn off this warning by adding the following settings in "settings.json":

"python.linting.pylintArgs": [
    "----extension-pkg-whitelist=1xml"
  ],

Result:

enter image description here

Update:

You could use the following settings to turn off specific ("undefined-variable") pylint information:

"python.linting.pylintArgs": [
      "--disable=E0602"
    ]

It is recommended that you modify the code first (there is no code error, the code can be executed), and then turn off such warnings.

Jill Cheng
  • 9,179
  • 1
  • 20
  • 25