The accepted answer won't fix the error when importing own modules.

Use the following setting in your workspace settings .vscode/settings.json:

"python.autoComplete.extraPaths": ["./path-to-your-code"],

Reference: Troubleshooting, Unresolved import warnings

UPDATE 2023

As mentioned by shmim python-language-server is deprecated and new closed source LSP Pylance's setting is configured as follows:

"python.analysis.extraPaths": ["./path-to-your-code"]
Answer from Shinebayar G on Stack Overflow
Discussions

Import could not be resolved in VS Code
I am trying to write a code in Azure Functions through VS Code, but in import it says "Import could not be resolved". Following is screenshot Python is installed, Azure Storage Account is installed Do I need to put them in some… More on learn.microsoft.com
🌐 learn.microsoft.com
1
0
November 17, 2022
flask - Import could not be resolved/could not be resolved from source Pylance in VS Code using Python 3.9.2 on Windows 10 - Stack Overflow
My Flask App server is running but I have three imports that cannot be resolved. I have tried: reinstalling the imports individually reinstalling requirements.txt I configured VSCode Workspace wi... More on stackoverflow.com
🌐 stackoverflow.com
vscode saying import could not be resolved but it definitely is
Two possible reasons: The way you run your code (it's current working directory) is different than the way you open it in vscode (base project directory) vscode thinks the python interpreter is different than the one you are actually using to run your code. in this case ctrl+shift+p from vscode, type interpreter and pick select interpreter and pick a different python there. More on reddit.com
🌐 r/learnpython
18
6
July 9, 2021
python - VSCode "Import X could not be resolved" even though listed under `help('modules')` - Stack Overflow
I'm on day 1 of Python and trying to import SciPy into a project. I installed it via pip install on ElementaryOS (an Ubuntu derivative). I have verified it's existence via: $ python >>> ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
gist.github.com › krisbolton › 20159d66f1d919c9c2380c96b6ac3915
VSCode import could not be resolved by Pylance (reportMissingImports) · GitHub
In VSCode open settings by pressing ctrl + , and a search box will appear. Search for and select "pylance". Find the "Extra paths" item. Press the "add item" button and copy & paste the path you found in step 3. The squiggly lines and the error should have gone. Pylance now knows where to find the module you were attempting to import. N.b. you can exit the python interpreter by typing exit().
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1093387 › import-could-not-be-resolved-in-vs-code
Import could not be resolved in VS Code - Microsoft Q&A
November 17, 2022 - For your first issue Import could not be resolved in VS Code for pandas it will resolve once the panda is installed on your function environment locally. Please make sure that you are adding all the dependencies in requirement.txt file for any ...
🌐
Safjan
safjan.com › home › note › vscode problem - import could not be resolved...
VSCode problem - import could not be resolved from the source (Pylance)
September 10, 2024 - Open the Command Palette (Ctrl+Shift+P) and select "Python: Select Interpreter". Choose the interpreter from your virtualenv. Make sure your virtualenv is activated in the terminal you're using within VSCode.
🌐
k0nze
k0nze.dev › posts › python-relative-imports-vscode
Python Relative Imports in VSCode (Fix ModuleNotFoundError and Auto-completion) | k0nze
January 30, 2024 - Then the project structure could look like this: Now main.py can’t access MyClass using the import statement from above because libs/my_package is not in the folder that main.py is in, and when running main.py, the following ModuleNotFoundError is raised: There is a dirty fix to remove the ModuleNotFoundError by extending the PYTHONPATH inside of main.py.
🌐
YouTube
youtube.com › watch
How to Fix Import Errors in Visual Studio Code - Solve Python Import VSCode - YouTube
🚀 How to Fix Import Errors in Visual Studio Code | Solve Python Import Issues in VS Code (2025)Are you facing import errors in VS Code while running your Py...
Published   February 17, 2025
Find elsewhere
🌐
Position Is Everything
positioniseverything.net › home › python unresolved import: 5 causes and their solutions
Python Unresolved Import: 5 Causes and Their Solutions - Position Is Everything
December 29, 2025 - The following are the important things about VS Code and how you can get the best from it when you’re working with Python modules: A wrong Python interpreter will prevent VS Code from resolving a Python module.
🌐
GitHub
github.com › microsoft › pylance-release › issues › 4873
Import Errors in Visual Studio Code with Python · Issue #4873 · microsoft/pylance-release
Checked and confirmed both Python files are set to UTF-8. Completely uninstalled and reinstalled both Python and VSC, ensuring all configuration files and settings were cleared. Changed the Python Language Server to Jedi in the settings.json ...
Author   microsoft
🌐
Sentry
sentry.io › sentry answers › vs code › fix pylance resolvemissingimports in vs code
Fix Pylance resolveMissingImports in VS Code | Sentry
July 15, 2024 - Select the Python interpreter in your virtual environment – it should be the top option, with a “Recommended” tag. If you previously installed fastapi to the virtual environment, the resolveMissingImports error should now disappear.
🌐
Reddit
reddit.com › r/learnpython › vscode saying import could not be resolved but it definitely is
r/learnpython on Reddit: vscode saying import could not be resolved but it definitely is
July 9, 2021 -

I'm getting this weird thing in vscode where my import is working properly but theres a yellow line under the module name and when I hover over that, it says module can't be resolved.

If I try and change how I access the module (using a relative path, perhaps), the yellow error line is no longer there but the code doesn't work as python or vscode doesn't recognise the module name/path

Does anyone have experience with this?

My code works but the yellow line is annoying.

I don't NEED to separate my code into different files but it would still be good to know what's going on here

Thank you

🌐
YouTube
youtube.com › blogize
Troubleshooting Import Could Not Be Resolved in Python with Visual Studio Code - YouTube
Summary: Resolve common import issues in Python when using Visual Studio Code (VSCode). Learn how to address errors like "import could not be resolved" using...
Published   September 4, 2024
Views   22
Top answer
1 of 7
73

The issue was indeed with Pylance. It was missing an "additional path" to where pip had installed the projects I wanted to import. To solve the issue:

First make sure you know the location of your import; you can find it with:

$ python
>>> import modulename
>>> print(modulename.__file__)

Then, once you know the location:

  1. Open settings (ctrl + ,)
  2. Search "pylance" or find it under "Extensions > Pylance"
  3. Find the "Extra Paths" config item
  4. Use "add item" to a add a path to the parent folder of the module. It will not do any recursive tree searching

And you should be good to go!

For a further example, you can see the image above where I had added the path /home/seph/.local/lib/python2.7/ to no avail. Updating it to /home/seph/.local/lib/python2.7/site-packages/ did the trick.

2 of 7
24

I had a similar problem in my setup as I create a virtual environment per project and install Jupyter there. Instead of a global setting change in the Pylance extension, I rather prefer to follow what states its troubleshooting guide.

Suppose your virtual environment is called venv and it is inside your project folder:

  • Create a folder called .vscode at the root of your project folder, if it does not already exist. Don't forget the dot in front of the name.
  • Create or edit the file .vscode/settings.json and include this tag:
{
    "python.analysis.extraPaths": ["./venv"]
}
  • Note that the path to your virtual environment is relative to the root project folder, not the folder containing the settings.json file.

I hope this helps.

🌐
Reddit
reddit.com › r/vscode › local python imports not recognized - "unresolved import"
r/vscode on Reddit: Local Python imports not recognized - "unresolved import"
May 17, 2020 -

I'm using the latest versions of VSCode, Python, and Python extension for VSC. I am running my code in a Virtual Environment as well.

Given an extremely simple folder structure like this:

\dev
 |_main.py
 |_other.py

from other import other in main.py is linting as "unresolved import 'other'" on the file name, i.e. the first "other".

The code however runs perfectly, so it isn't a syntax issue.

🌐
YouTube
youtube.com › techie dude
Python Module Import Error in VS Code Solved | Virtual Environment in Visual Studio Code - YouTube
In this video, I have explained how to solve import issues in visual studio code.
Published   June 12, 2021
Views   252K
🌐
howto Go-it
howto.goit.science › home › linux
Troubleshooting Import Could Not Be Resolved in Python with Visual Studio Code -
September 6, 2024 - Virtual Environment: Your VSCode may not be using the correct Python interpreter. Path Issues: Incorrect or relative module paths can cause import errors. Pylance Configuration: Pylance settings might need adjustments to recognize the modules ...
🌐
Python.org
discuss.python.org › python help
Import PyQt6,QtCore could not be resolved in VSCode - Python Help - Discussions on Python.org
April 10, 2024 - if I run my Python code in Idle it runs but all the menu items are missing (presumably because they came from PyQt. Running it in vsCode shows the import PyQt6.QtCore (also .QtGui and .QtWidgets) underlined in red in th…
🌐
MAC Address Lookup
aruljohn.com › home › articles › tech
Python Visual Studio Code Error: Import MODNAME could not be resolved
August 13, 2025 - This is my working solution for VS Code lint error Import MODNAME could not be resolved for Python program which worked perfectly fine. Extra Paths. Add Item.
🌐
GitHub
github.com › microsoft › vscode › issues › 151832
Import module could not be resolved from source · Issue #151832 · microsoft/vscode
June 11, 2022 - Issue Type: Bug 1- I installed the module "requests" using the command "pip install requests" and checked that it is indeed exist on my machine using the command "pip list". 2- I wrote a python file that contains the line "import request...
Author   microsoft