When I did not install the module "flask" in the Python environment currently used in VSCode:

Please use the command "pip --version" to check the source of the module installation tool "pip", the module is installed at this location:

Then, we can use the command "pip show flask" to check the installation location of the module "flask": (It checks whether the installation location of the module is consistent with the Python environment displayed in the lower left corner of VSCode.)

If the "reportMissingModuleSource" message is still displayed here, please reload VS Code.
(F1, Developer: Reload Window)

When I did not install the module "flask" in the Python environment currently used in VSCode:

Please use the command "pip --version" to check the source of the module installation tool "pip", the module is installed at this location:

Then, we can use the command "pip show flask" to check the installation location of the module "flask": (It checks whether the installation location of the module is consistent with the Python environment displayed in the lower left corner of VSCode.)

If the "reportMissingModuleSource" message is still displayed here, please reload VS Code.
(F1, Developer: Reload Window)

Are you using a Virtualenv? If so make sure that VSCode is using the virtualenv as your python interpreter, otherwise it will not be able to pick up the packages that you installed inside this virtualenv.
To do so, click on the Python interpreter in your bottom bar, you should get a list of possible python interpreters including your virtualenv.
python - ImportError: "flask_sqlalchemy" could not be resolved - Stack Overflow
python - Import "flask" could not be resolved Pylance - Stack Overflow
python - import flask could not be resolved from source pylance - Stack Overflow
Import x could not be resolvedPylancereportMissingImports - wsl + asdf-vm
Videos
I had the same error. Changed my system python by doing the following in VS Code: Under the view menu select 'show command pallet'. One of the commands you can then select from the command palette is 'Python: Select Interpreter'. Selecting this option will allow you to choose which version of python to use.
This post is pretty old but I found a different solution that might help others out. For me, the issue was my IDE/Python (venv). I am using Visual Studio ver. 1.57.1 as of now on Windows 10.
- Open Visual Code.
- Go to 'View' on the toolbar.
- Click on 'Command Palette...' (or press CTRL + SHIFT + P on Windows).
- Search for: 'Python Select Interpreter'.
- Click on: 'Enter interpreter path...' followed by 'Find...'.
- Go to your (venv) scripts folder:
project_folder/venv/Scripts. - Select
python.exeorpythonw.exeinside of yourproject_folder/venv/Scriptsfolder.
That's all.
The Flask-SQLAlchemy was installed in my virtual environment (venv). But my VSCode was using the system/PC Python interpreter to find the packages instead of the venv.
Hope this helps someone else out.
- Firstly, create a virtual environment on your terminal.
- Then install Flask by running pip install flask.
- After installing, press CTRL+SHIFT+P.
- Search for Python Interpreter.
- Select your virtual environment.
The problem will be fixed. I have also faced the same issue, but I resolved it by following this procedure.
When I did not install the module "flask", I ran into the problem you described:

The reason is that the module "flask" is not installed in the Python environment we currently use in VSCode.
Please use the shortcut key Ctrl+Shift+` to open a new VSCode terminal, it will automatically enter the currently selected environment, and then use the command "pip show flask" to check the installation location of the module "flask":

If it still shows that the module could not be resolved, it is recommended that you reinstall the module "flask".
I was having the same problem, I messed around a lot reinstalling things so I'm not 100% sure what the perfect solution is but this is what finally worked for me.
View -> Command Pallete -> Python: Select Interpreter -> Select the version that says 'Global'
Then follow the same steps but instead select the version that says 'Recommended'.
I am assuming it somehow reinitialized the version of python I was trying to use.
I was having the same problem, but I was using pipenv which sets up a special environment for the execution with the python modules installed in that environment. When I execute the "pipenv shell" command, the response shows me the environment that is created and has the version of the interpreter that should be used for this environment.
The line I get is: myuser@Pspec7:~/pydev/flask$ . /home/myuser/.local/share/virtualenvs/flask-E0DF0fBp/bin/activate
When you get to the point where you can select your interpreter: In the interpreter list look for the path that corresponds to your environment.
From the line above, my interpreter was: Python 3.8.10 ('flask-E0DF0fBp')
This was for me. You need to look for your correspoding string. Without setting the interpreter correctly, it cannot look through the packages you have installed.
I am using virtualenv and I install flask-sqlaclchemy using pip install Flask-SQLAlchemy but still the vscode give an error
install flask-sqlalchemy out of the virtual environment first.
$ pip install Flask-SQLAlchemy
I had these 2 errors:
Unable to import 'flask_sqlalchemy'
Unable to import 'flask_migrate'
The problem was this line in my models.py file:
id = db.Column(db.Integer, primary_key=True)
I had a comma at end of the line and it caused me an hour of wasted time.
Did you install flask-sqlalchemy? It looks like you have SQLAlchemy installed but not the Flask extension. Try pip install Flask-SQLAlchemy in your project's virtualenv to install it from PyPI.
I just experienced the same problem. Apparently, there is a new distribution method, the extension code is no longer stored under flaskext.
Source: Flask CHANGELOG This worked for me:
from flask_sqlalchemy import SQLAlchemy
I upgraded my pip and made sure that I installed sql-alchemy. I also am not runnign a virtual environment. How would I fix this issue ?