My problem is after installing Python and PyQt5 in vs code, when I run the code he show me this problem:
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.
( 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:
What should I do to solve my issue?
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:
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.