You should create a pyrightconfig.json file or pyproject.toml file at the root of your project. For example, if it's a Django project, you should have one of those files where manage.py is placed. Then, set include parameter and add the subdirectories (or app folders in Django terms).

You can consult this sample config file. See this issue ticket.

For example, if this were my project structure:

├── manage.py
├── movie
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
├── moviereviews
│   ├── asgi.py
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── pyproject.toml

my pyproject.toml would be:

[tool.pyright]
include = ["movie", "moviereviews"]

If you are working within a Python virtual environment, set venvPath and venv. Consult the documentation for an exhaustive list of options.

Answer from harsath 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?

Discussions

python - "Import could not be resolved" reported by Pyright - Stack Overflow
I've just started using Pyright. Running it on files that run perfectly well I get plenty of errors. This question is similar, but refers to one's own modules. For example Import "numpy" could no... More on stackoverflow.com
🌐 stackoverflow.com
Pyright "import ' ' cannot not be resolved" identifying imports inside python packages
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. More on github.com
🌐 github.com
3
February 28, 2024
Import could not be resolved
Describe the bug pyright is throwing errors despite VS Code correctly identifying all the python libraries etc. Screenshots or Code Output from pyright in VS Code console Pyright language server st... More on github.com
🌐 github.com
7
June 4, 2019
Pyright unable to resolve imports that are in my PYTHONPATH
I’m running neovim with nvim-lspconfig plugin with pyright. The structure of the repo is a little strange, so I’ve got a PYTHONPATH environment variable set up to help python find all the code. Here’s a simple example: $ mkdir demo; cd demo $ git init # necessary to get lspconfig's root_dir ... More on neovim.discourse.group
🌐 neovim.discourse.group
0
1
October 27, 2021
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 ...
🌐
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
🌐
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 - All dependencies must be installed within that specific environment to function correctly. PYTHONPATH Misconfiguration: The PYTHONPATH environment variable should include directories where your modules reside. Misconfigurations here can lead to significant acquisition challenges. Identifying these frequent causes is essential for resolving Copyright issues effectively, especially when a pyright import could not be resolved.
🌐
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 › 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
Find elsewhere
🌐
GitHub
github.com › neovim › nvim-lspconfig › issues › 1861
lsp server pyright import could not be resolved · Issue #1861 · neovim/nvim-lspconfig
Description I mean that the file account/views/oj.py cannot import files in the directory、options、utils、problem. And,the pyright installed by nvim-lsp-installer and nvim-lsp-config in neovim all config items are default. But when i use v...
Author   neovim
🌐
Neovim Discourse
neovim.discourse.group › language server protocol (lsp)
Pyright unable to resolve imports that are in my PYTHONPATH - Language Server Protocol (LSP) - Neovim Discourse
October 27, 2021 - I’m running neovim with nvim-lspconfig plugin with pyright. The structure of the repo is a little strange, so I’ve got a PYTHONPATH environment variable set up to help python find all the code. Here’s a simple example: $ mkdir demo; cd demo $ git init # necessary to get lspconfig's root_dir automatically set, this is discussed later $ cat test.py import foo print(foo) $ cat subdir/foo.py PI=22/7 Note how that import foo shouldn’t work (without a custom PYTHONPATH) because foo.py is in a subd...
🌐
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?

🌐
Basedpyright
docs.basedpyright.com › latest › usage › import-resolution
Import resolution - basedpyright
Import hooks can provide an editable installation that is a more accurate representation of your real installation. However, because resolving module locations using an import hook requires executing Python code, they are not usable by Pyright and other static analysis tools.
🌐
GitHub
github.com › microsoft › pyright › issues › 352
Import could not be resolved when folder matches python module name · Issue #352 · microsoft/pyright
November 23, 2019 - If there's a folder and python module with the same name (obviously not a great idea, but the error didn't say what was going on) then pyright fails to resolve an import of the module.
Author   microsoft
🌐
GitHub
github.com › microsoft › pyright › issues › 4039
Import couldn't be resolved when a subdirectory package contains a pyproject.toml file · Issue #4039 · microsoft/pyright
October 12, 2022 - That is, if the package is built using setup.py it's fine, but note that you still can't have pyproject.toml file there even when used with setup.py. Basically, pyright recognise the pyproject.toml inside the foo/bar folder as a module instead of foo/bar/bar, so when it resolves import bar, it's looking at foo/bar and not foo/bar/bar.
Author   microsoft
🌐
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 › 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 › 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
🌐
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 - A common cause of unresolved imports is a configuration problem with the Python environment being used. If the module is installed locally but not globally recognized, problems can arise.
🌐
Devgex
devgex.com › en › article › 00032844
Analysis and Solution for "Import could not be resolved" Error in Pyright - DevGex
December 1, 2025 - Validate Solution: After configuration, restart VS Code or reload the window. Pyright should now correctly resolve all import statements. Verify by checking if the "Import could not be resolved" error has disappeared from the Problems panel.
🌐
GitHub
github.com › microsoft › pyright › issues › 4340
Pyright cannot resolve 3rd party libraries imports - Neovim · Issue #4340 · microsoft/pyright
December 14, 2022 - I have shown an example image below with numpy.array() [2]. But with other 3rd party libraries, for example, cv2 (OpenCV) I am shown the LSP suggested completion for importing but I do not get LSP completions or definitions when trying to use cv2 functions. [3] Another example is with PyTorch I get import cannot be resolved errors however, I still am able to get LSP suggested completions and definitions for PyTorch functions, example image shown below [4]. bs4 says "Import bs4 could not be resolved from source", however LSP suggested completions and definitions still work.
Author   microsoft
🌐
GitHub
github.com › microsoft › pyright › discussions › 8557
[Resolved] Resolve bazel dependencies: Import "..." could not be resolved · microsoft/pyright · Discussion #8557
For example, the name of one of these dependencies is "my_dependency". In the BUILD file, I inject this dependency using "@my_dependency". In the python script I use "import my_dependency", and everything works ok. But, using pyright command line, i've got the error Import "my_dependency" could not be resolved.
Author   microsoft