close

[Solved] import flask could not be resolved from source pylance

Hello Guys, How are you all? Hope You all Are Fine. When I am writing from flask import Flask One Yellow line is coming up under flask and stating Import “flask” could not be resolved from source Pylance (reportMissingModuleSource) in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How import flask could not be resolved from source pylance Error Occurs ?

When I am writing from flask import Flask One Yellow line is coming up under flask and stating Import “flask” could not be resolved from source Pylance (reportMissingModuleSource).

Import “flask” could not be resolved from source Pylance (reportMissingModuleSource),
“flask” could not be resolved from source Pylance (reportMissingModuleSource),
resolved from source pylance reportmissingmodulesource,
source pylance reportmissingmodulesource,
“flask” could not be resolved from source Pylance

How To Solve import flask could not be resolved from source pylance Error ?

  1. How To Solve import flask could not be resolved from source pylance Error ?

    To Solve Import flask could not be resolved from source Pylance (reportMissingModuleSource) Error just 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 1

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”.

Solution 2

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.

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.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also Read

Please Rate Our Solution to Motivate Us For Give Our Best

Leave a Comment