On my computer I have 3 Pythons, a 3.6 from Anaconda, and a 2.7 & 3.7 that are regular python. Prompted by a nudge from this GH issue, I switched from the Anaconda 3.6 to the 3.7, and back again, and the problem went away.

I think that this is the case because your .vscode/settings.json (the following is mine), doesn't have that last line until you change your python, at which point, that last line is put in and Pyright has something to look at.

{
  "python.linting.enabled": true,
  "python.formatting.provider": "black",
  "python.pythonPath": "C:\\Users\\ben\\Anaconda3\\python.exe"
}
Answer from Ben on Stack Overflow
🌐
Reddit
reddit.com › r/neovim › pyright diagnoses error "import "..." could not be resolved" for absolute import however the code works. when i change it to a relative import the diagnosis dissapears and everything looks okay however on execution the does not works.
r/neovim on Reddit: Pyright diagnoses error "Import "..." could not be resolved" for absolute import however the code works. When I change it to a relative import the diagnosis dissapears and everything looks okay however on execution the does not works.
September 6, 2022 -

As the title says, I am running into a weird situation with pyright in neovim. The pyright LSP is attached to my session and diagnoses an `import could not be resolved error` error. (https://gyazo.com/2ccaa53a09a6908ed99e83814458ec28).

However, when I run the `main.py` file everything works as expected. When I change the absolute import in the `another_module.py` to `from ..folder.module import hello_world` the diagnosis disappears. The code however then throws an ImportError `attempted relative import beyond top-level package`. Referring to the `..folder.module import hello_world` line. This is my `main.py` file: https://gyazo.com/10125d588b6247a79ea6c809acccda08

Anyone has any idea what is going on or has run into this before?

People also ask

What are common causes of the 'pyright import could not be resolved' error?
Common causes include: 1. Incorrect module path. 2. Missing packages in the Python environment. 3. Issues with the virtual environment not being activated. 4. Misconfiguration of the PYTHONPATH environment variable.
🌐
blog.kodezi.com
blog.kodezi.com › how-to-fix-the-pyright-import-could-not-be-resolved-error-a-step-by-step-guide
How to Fix the Pyright Import Could Not Be Resolved Error: A ...
What does the error indicating that the pyright import could not be resolved mean?
This error occurs when the tool cannot find a module or package specified in your import statement.
🌐
blog.kodezi.com
blog.kodezi.com › how-to-fix-the-pyright-import-could-not-be-resolved-error-a-step-by-step-guide
How to Fix the Pyright Import Could Not Be Resolved Error: A ...
How can Kodezi help with resolving pyright import issues?
Kodezi is an AI-powered programming tool that analyzes bugs and corrects code, enhancing productivity by reducing time spent on debugging and optimizing code.
🌐
blog.kodezi.com
blog.kodezi.com › how-to-fix-the-pyright-import-could-not-be-resolved-error-a-step-by-step-guide
How to Fix the Pyright Import Could Not Be Resolved Error: A ...
🌐
Kodezi
blog.kodezi.com › how-to-fix-the-pyright-import-could-not-be-resolved-error-a-step-by-step-guide
How to Fix the Pyright Import Could Not Be Resolved Error: A Step-by-Step Guide
August 13, 2025 - By staying vigilant about these scenarios and utilizing Kodezi CLI as your Swiss-Army Knife for programmers, you can address potential import errors in your code, including cases where the pyright import could not be resolved, before they escalate, enhancing your overall coding efficiency. This tool empowers developers to tailor their experience through configuration files, such as pyrightconfig.json, which allow for customized behavior.
🌐
GitHub
github.com › microsoft › pyright › issues › 1809
Pyright could not resolve import · Issue #1809 · microsoft/pyright
April 30, 2021 - Describe the bug Pyright is unable to resolve imports when using executionEnvironments in the pyrightconfig.json. This happens ever since upgrading to pyright 1.1.136, and happens independent of the import as long as it is an additionally installed import (e.g. standard library works fine). I am unsure of the exact version I came from but I verified version 1.1.96 works fine for me. For example: "Import 'docker' could not be resolved"
Author   microsoft
🌐
GitHub
github.com › zed-industries › zed › issues › 19344
`Pyright: Import could not be resolved` with multiple `pyrightconfig.json` and `extraPaths` option · Issue #19344 · zed-industries/zed
October 17, 2024 - Zed doesn't seem to correctly handle multiple pyrightconfig.jsons with extraPaths option at the moment.
Author   zed-industries
🌐
Reddit
reddit.com › r/neovim › pyright import ... could not be resolved
r/neovim on Reddit: Pyright Import ... could not be resolved
January 22, 2023 -

I'm running into what seems to be a rather common problem with `Pyright` where it's unable to resolve an import. For example, I am getting Pyright: Import "iterm2" could not be resolved.

For reference, I am using the default Pyright configs just to keep things simple. My directory structure also looks something like this:

RootDir/
  - Dir
  - Dir
  - Scripts
    - myFile.py # Where the import error arises
    - OtherDirs
    - setup.cfg

When I do an :LspInfo I see that the LSP is attached, and it tends to work for the standard library, just not for other imports.

From the research I have done thus far, it seems like every Python project you work on requires a unique pyrightconfig.json file, which to me seems like I may be misreading what I have found because it feels cumbersome.

I know that you can modify the LSP settings for Pyright as in the link above, but do you also require a project-based file in addition to the LSP settings for Pyright to properly understand imports?

🌐
Debuglab
debuglab.net › home › 2024 › february › 13 › “import could not be resolved” reported by pyright
“Import Could Not Be Resolved” Reported By Pyright - Debuglab | Debugging, Profiling & Error Hunting
December 24, 2025 - Remember, the Pyright error message “import could not be resolved” typically signifies a configuration problem in relation to your project directory and file structure. By properly configuring the `pyrightconfig.json`, the issue can be quickly ...
Find elsewhere
🌐
GitHub
github.com › microsoft › pyright › issues › 3378
import could not be resolved · Issue #3378 · microsoft/pyright
Describe the bug I am use neovim , lsp server is pyright . the version is 1.1.239 · When importing modules in the upper directory in the file. point out error " import could not be resolved "
Author   microsoft
🌐
Readthedocs
micropython-stubs.readthedocs.io › en › main › 22_vscode.html
Configuring VSCode, Pylance or Pyright — Micropython-Stubs 1.23.0 documentation
Note: If you’ve previously set a language server and want to try Pylance, make sure you’ve set "python.languageServer": "Default" or "Pylance" in your settings.json file using the text editor, or using the Settings Editor UI. ... If you have created a .venv make sure to also select it in VSCode using F1, >Python: select interpreter or the UX ... After installing the stubs you may see some warnings that the source code for some of the commonly used modules are not found: Import "machine" could not be resolved from source Import "time" could not be resolved from source Import "urequests" could not be resolved from source
🌐
GitHub
github.com › microsoft › pyright › issues › 57
Import could not be resolved for pip packages and local modules · Issue #57 · microsoft/pyright
April 5, 2019 - Describe the bug When opening a file that is known to work in python, all pip based modules and local (to the project) modules are flagged, e.g.: Import 'boto3' could not be resolved To Reproduce Import a pip based module or local module...
Author   microsoft
🌐
GitHub
github.com › zed-industries › zed › issues › 8540
Pyright "import ' ' cannot not be resolved" identifying imports inside python packages · Issue #8540 · zed-industries/zed
February 28, 2024 - This correctly works internally when running or using anything from the package. However, pyright throws an issue: import anchor_sdk could not be resolved (reportMissingImports) in the IDE.
Author   zed-industries
🌐
GitHub
github.com › microsoft › pyright › issues › 382
Import 'orjson' could not be resolved · Issue #382 · microsoft/pyright
December 1, 2019 - Describe the bug When using pyright extension in VSCode, importing orjson package gives me an error: "Import 'orjson' could not be resolved". When I disable pyright, autocomplete works perfectly for orjson. To Reproduce Install python fo...
Author   microsoft
🌐
Devgex
devgex.com › en › article › 00032844
Analysis and Solution for "Import could not be resolved" Error in Pyright - DevGex
December 1, 2025 - This process ensures Pyright receives correct interpreter information. Validate Solution: After configuration, restart VS Code or reload the window. Pyright should now correctly resolve all import statements.
🌐
GitHub
github.com › microsoft › pyright › issues › 143
Import could not be resolved · Issue #143 · microsoft/pyright
June 4, 2019 - Could not import 'dotenv' in file '/Users/bfelbo/code/pulse/pulse.py' Looking for typeshed stdlib path Attempting to resolve using root path '/Users/bfelbo/.vscode/extensions/ms-pyright.pyright-1.0.36/typeshed-fallback/stdlib/3.7' Could not find directory '/Users/bfelbo/.vscode/extensions/ms-pyright.pyright-1.0.36/typeshed-fallback/stdlib/3.7/dotenv' Did not find file '/Users/bfelbo/.vscode/extensions/ms-pyright.pyright-1.0.36/typeshed-fallback/stdlib/3.7/dotenv.pyi' or '/Users/bfelbo/.vscode/extensions/ms-pyright.pyright-1.0.36/typeshed-fallback/stdlib/3.7/dotenv.py' Attempting to resolve usi
Author   microsoft
🌐
GitHub
github.com › microsoft › pyright › issues › 2257
Import could not be resolved · Issue #2257 · microsoft/pyright
September 2, 2021 - Describe the bug I'm getting an unexpected Import could not be resolved. To Reproduce Create a "project" with the following project tree: ├── pyrightconfig.json └── stuff ├── arch │ └── linux.py │ └── base.py <-- symlink of stuff/common/base.py ├── common │ └── base.py └── lol └── loller.py 4 directories, 4 files ·
Author   microsoft
🌐
Reddit
reddit.com › r/learnpython › pyright imports cannot be resolved: question regarding setup
r/learnpython on Reddit: Pyright Imports Cannot Be Resolved: Question Regarding Setup
January 22, 2023 - From the research I have done thus far, it seems like every Python project you work on requires a unique pyrightconfig.json file, which to me seems like I may be misreading what I have found because it feels cumbersome. I know that you can modify the LSP settings for Pyright as in the link above, but do you also require a project-based file in addition to the LSP settings for Pyright to properly understand imports? ... Nobody's responded to this post yet. Add your thoughts and get the conversation going. ... Pyright Import ... could not be resolved
🌐
Iditect
iditect.com › faq › python › quotimport-could-not-be-resolvedquot-reported-by-pyright.html
"Import could not be resolved" reported by Pyright
If PYTHONPATH is incorrectly set, Pyright may not locate the modules. Ensure it's set to include the necessary paths. export PYTHONPATH="/path/to/your/project" # For Unix-based systems set PYTHONPATH=C:\path\to\your\project # For Windows # Restart your IDE or text editor after setting PYTHONPATH ...
🌐
CSDN
devpress.csdn.net › python › 630459697e6682346619a529.html
"Import could not be resolved" reported by Pyright_python_Mangs-Python
August 23, 2022 - What does it mean, and how do I resolve it? On my computer I have 3 Pythons, a 3.6 from Anaconda, and a 2.7 & 3.7 that are regular python. Prompted by a nudge from this GH issue, I switched from the Anaconda 3.6 to the 3.7, and back again, and the problem went away. I think that this is the case because your .vscode/settings.json (the following is mine), doesn't have that last line until you change your python, at which point, that last line is put in and Pyright has something to look at.