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

We Are Going To Discuss About Import “flask” could not be resolved from source Pylance (reportMissingModuleSource). So lets Start this Python Article.

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

  1. How to solve Import “flask” could not be resolved from source Pylance (reportMissingModuleSource)

    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)

  2. Import “flask” could not be resolved from source Pylance (reportMissingModuleSource)

    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 1

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

enter image description here

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

enter image description here

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

enter image description here

If the “reportMissingModuleSource” message is still displayed here, please reload VS Code.

(F1, Developer: Reload Window)

enter image description here

Original Author Jill Cheng Of This Content

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.

Original Author Marius Kimmina Of This Content

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!

Original Author Icaru5 Of This Content

Solution 4

For Linux Mint and for those who have installed flask, but VSCode doesn’t find it:

  1. check the Flask path: pip show flask (should be smth like
    Location: /home/<username>/.local/lib/python3.8/site-packages
  2. in VSCode click left bottom button and choose the python interpreter, in my case I changed it from python3.9 to python3.8 as we can see it in the flask path.

Original Author Roy O’Bannon Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment