- 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.
Answer from Md. Saroar Jahan on Stack Overflow- 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".
Not sure if this is the right place for this question. I'm trying to use flask in visual studio code and went through the process of installing it. When I try to import it, I get a message saying "Import 'flask' could not be resolved from the source Pylance(reportMissingModuleSource)". How can I fix this?
Does this stack overflow question solve your issue? https://stackoverflow.com/a/65802367/11591238
Open a terminal in your project dir. Vscide should nothing to do with getting flask working. I don’t know how your env is configured though.
‘pip install pipenv’
‘pip shell’
‘pipenv install flask’
You should be good to go. Pipenv is my new lover 💙💙
Hope this helps
Videos
As seen below, I have done pip install Flask in a set up venv. Listing the libraries and visiting the file itself also shows that I have Flask installed. However, when I type
from flask import Flask
The words flask and Flask do not get highlighted. The word "Flask" only gets highlighted under this circumstance.
import Flask
I've tried on two different devices and I am stumped looking for help. TIA.
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.