2

While working on a Python script in which I had to import opencv, VSCode throws a lot of errors whenever I call the opencv package for any function.

Is there something I haven't set up on my editor?

enter image description here

Thanks for any help.

Gama11
  • 31,714
  • 9
  • 78
  • 100
IvanS95
  • 5,364
  • 4
  • 24
  • 62
  • 3
    PyLint in this case is just wrong. `cv2` does indeed have a function `CascadeClassifier`, I just checked. IDLE knows about it, even if PyLint doesn't. This appears to be a known problem: for example https://stackoverflow.com/questions/31907762/pylint-to-show-only-warnings-and-errors – BoarGules Jun 02 '18 at 22:38
  • I see, as far as I can tell, it doesn't get in the way of compiling and running the script, it's just annoying to me having all those error messages when I know they are wrong – IvanS95 Jun 02 '18 at 22:44
  • 2
    I know it's annoying, but PyLint is a code *analyzer*. If the interpreter accepts the code, then PyLint is *wrong.* The only thing you can do in that case is to tell PyLint to shut up. – BoarGules Jun 02 '18 at 22:49
  • Lol, you're right, will do :) – IvanS95 Jun 02 '18 at 22:55
  • Also make sure that cv2 is installed and available to the selected environment as that can also help with Pylint's errors about not finding attributes on a module. – Brett Cannon Jun 04 '18 at 19:47
  • @BrettCannon how so? I mean, I definitely have cv2 package installed, the script runs fine as it is, however VSCode has never recognized the available functions of the package at all, thus it doesn't even highlights the syntax. Is there anything else I can do to improve that? – IvanS95 Jun 04 '18 at 20:56
  • @IvanS95 if "Run Python File in Terminal" runs fine, then it's a Pylint issue. You could contemplate using a different linters like flake8. – Brett Cannon Jun 05 '18 at 18:54

0 Answers0