Import "flask" Could Not Be Resolved From Source Pylance (reportmissingmodulesource)
Solution 1:
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
)
Solution 2:
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.
Solution 3:
I had a similar issue while trying to import flask on vscode. I fixed it by using anaconda. Simply you install the flask module in your created environment example screenshot.
How to create a virtual env in anaconda: 1. On the left sidebar, click on environments. 2. Click create (at the bottom). 3. At the pop-up window, give your vir.env a name and select the language version. 4. Once created, you can start installing different modules in your environment.
I hope that helps!
Solution 4:
For Linux Mint and for those who have installed flask, but VSCode doesn't find it:
- check the Flask path:
pip show flask
(should be smth likeLocation: /home/<username>/.local/lib/python3.8/site-packages
- in VSCode click left bottom button and choose the python interpreter, in my case I changed it from
python3.9
topython3.8
as we can see it in the flaskpath
.
Solution 5:
That's because you have not chosen your path correctly,
type:
pipenv --venv
then it will show you where your virtual env is installed. Check where the packages are installed in your env, and then type what comes to you from the shell\scripts or whatever\python, and the packages will work.
Post a Comment for "Import "flask" Could Not Be Resolved From Source Pylance (reportmissingmodulesource)"