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)

python - Visual Studio: Getting a "reportMissingModuleSource" error, and can't fix - Stack Overflow
python - Import "flask" could not be resolved from source Pylance (reportMissingModuleSource) - Stack Overflow
'reportMissingModuleSource' warning for requests.packages.*
vs code - reportMissingModuleSource with venv
Videos
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.
Hello ! I'm new to python and i have a problem, im running VSC on my chromebook (i know), and when i want to import modules (like matplotlib or pandas) i get the same error message
"Import "pandas" could not be resolved from source Pylance(reportMissingModuleSource)"
It works fine on my other computer (running Windows) but not on this one. Is it a problem with Linux or something i forgot to do when downloading VSC maybe ?
Pylance requires you to set the Python PATH:
If you're in Mac/Linux, use:
which python3
And in Windows (Command Prompt cmd.exe):
where python
So that the path in which your Python is installed is returned.
Copy that path.
Go to your vscode and open the settings.json file (CTRL + SHIFT + P, and type "settings.json" at search bar)
Add the following key to the json file:
"python.defaultInterpreterPath": "<PATH RETURNED ABOVE>"
The path may look like
"C:\\Users\\YOURUSERNAME\\anaconda3\\bin\\python.exe on Windows or "/usr/local/bin/python3" on Mac/Linux.
Note: backslashes in settings.json must be escaped with an additional backslash, so C:\Users becomes "C:\\Users".
The following documentation provides more information about how to configure Python for Visual Studio Code: https://code.visualstudio.com/docs/python/settings-reference
Also, on some occasions, you might have configured your environment by adding custom paths that Pylance can not detect.
In that case, you can use the python.analysis.extraPaths parameter to add more paths to your project, such as :
"python.analysis.extraPaths": ["app", "another/path/etc"]
(Source: https://dev.to/climentea/how-to-solve-pylance-missing-imports-in-vscode-359b)
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.
I finally figured out what was wrong. There seems to be an open issue with LSP Notebooks experiment on vscode that affects Jupyter Notebooks in the editor. The solution seems to be to set the "python.pylanceLspNotebooksEnabled" flag to False which by default is set to True and it fixes the problem of this error in Jupyter Notebooks in vscode.


This problem only seems to affect the docstring but doesn't affect autocomplete. Thanks to others who tried to help with this question and hope it helps those who might come across the same problem.
In my case the problem was in pyproject.toml file with extraPaths option specified. It seems to have precedence over the python.analysis.extraPaths setting in vs code.
I also received similar an error on my IDE VSCode and currently using mac m1 .First we need to make sure that the python3 interpreter version from terminal version is the same with our python version selection in VSCode.
- open terminal.
- type 'python3'
- then you will see your python version.(my python3 version is 3.9.12)

open your IDE VSCode
open any/current folder that related to python project on IDE VSCode
Check your python version at the bottom right on IDE VSCode (in my case the python version is 3.10.64)
change or switch VSCode python version from 3.10.64 to 3.9.12 (same with your python version on your pc)
done
First, Uninstall pylance extensions from your VS Code. Close the VS Code, Reopen the VS Code, install pylance again.
It works for me!
Noob here. Currently dealing with a very simple yet frustratingly difficult to resolve problem importing python modules.
When using pip install in the terminal I get a Requirement Already Satisfied response in the console, however in code when Import the module, I get the error code pasted at the bottom. I also get this issue if I create a Python file and try to import it in my main.py
I think the issue is the path they're getting installed in is not where VSCode is looking, but I've been unable to find a way to resolve it. Either that, or pip install is using a different instance of python that isn't what VSCode is using? Very annoying. If you have a solution, please let me know! Thanks!
[{
"resource": "/Documents/Coding/VSCode/Projects/Photoeditor/PhotoEditor.py",
"owner": "_generated_diagnostic_collection_name_#0",
"code": {
"value": "reportMissingModuleSource",
"target": {
"$mid": 1,
"external": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportMissingModuleSource",
"path": "/microsoft/pyright/blob/main/docs/configuration.md",
"scheme": "https",
"authority": "github.com",
"fragment": "reportMissingModuleSource"
}
},
"severity": 4,
"message": "Import \"requests\" could not be resolved from source",
"source": "Pylance",
"startLineNumber": 2,
"startColumn": 8,
"endLineNumber": 2,
"endColumn": 16
}]