Had this even though I have installed flask.
it turns out that flask was installed on my system-installed Python on path: "C:\Users\alide\AppData\Local\Programs\Python\Python311\python.exe"
but the error was appearing because I was running the python file with MSYS2 interpreter on path: "C:\msys64\ucrt64\bin\python.exe"
the easy solution was to switch the interpreter in VSCode by pressing ctrl+shift+p and typing "Python: Select Interpreter" and changing the interpreter to the system interpreter in the path "C:\Users\alide\AppData\Local\Programs\Python\Python311\python.exe"