Please use "pip show opencv-python" in the VSCode terminal to check where the module "cv" is installed, then click on the Python environment in the lower left corner of VSCode and change it to the environment where the module "cv" is installed.

Run:

More reference: Environment in VSCode.
Answer from Jill Cheng on Stack OverflowVideos
Please use "pip show opencv-python" in the VSCode terminal to check where the module "cv" is installed, then click on the Python environment in the lower left corner of VSCode and change it to the environment where the module "cv" is installed.

Run:

More reference: Environment in VSCode.
I think there are more than one python installation in your machine one must be installed outside the VS code and other one installed in VS code.
And your OpenCV is installion is not mapped with python installation that uses vs code .
You need to configure the pyhon version in the VS code that is mapped with OpenCV.
- To check all the python installation in your machine using following command in the cmd prompt
where python
Then check vs code is mapped with which version of python using below statment in the python file
import sys
print(sys.executable)
If the python path is different than openCV installed then need change by following below image

It just happened to me and I solved it installing both opencv-python and opencv-python-headless with pip and reloading the Visual Studio Code window right after it.
To install the needed packages, just run this command in the terminal:
$ pip install opencv-python opencv-python-headless
I had a similar issue so I installed opencv-python-headless (install opencv-python if not earlier) and reloaded the VScode window.
pip install opencv-python-headless
However, some methods like imshow() kept failing:
cv2.error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
This was resolved by installing opencv-contrib-python. You can install it by running the following code in your terminal:
pip install opencv-contrib-python
» pip install opencv-python
I had the exact same problem as you, though updating cv2 didn't solve my problem though.
If you come across this... as of 2024, pylint changed their setting prefixes, which caused your Unknown Configuration Setting error. To fix it, open settings.json (Ctrl+Shift+P, > "Preferences: Open Settings JSON):

and update python.linting.pylintArgs to pylint.args.
The result should look like this:
"pylint.args": [
"--generated-members=cv2.*"
],
For whatever reason, all solutions I found online don't work.
Changing settings.json didn't work, switching linter didn't work, there wasn't such an option. Even completely uninstalling Visual Studio Code and removing all the files except settings and user history, and then reinstall VS Code and the extensions failed to solve the problem.
So I eliminated the impossible causes. This means other things must be the cause.
I have of course installed OpenCV, and my code works correctly in the console, and this interpreter is the same one used by Visual Studio Code.
I just tried to update the cv2 version via pip3.10 install opencv-python --upgrade, this uninstalled opencv-python-4.7.0.72 and installed opencv-python-4.9.0.80. I then reloaded Visual Studio Code.
And this worked. This fixed the problem, hovering over function names showed their arguments and return type, and there is also autocomplete.
I have no idea why this worked. I will leave this answer to anyone who faced the same problem.