Import my own module could not be resolved
See original GitHub issueOutput of :CocCommand pyright.version
:
[coc.nvim] coc-pyright 1.1.161 with Pyright 1.1.161
Output of :CocCommand workspace.showOutput Pyright
:
Workspace: C:\Users\MyPC Using python from C:\Users\MyPC\AppData\Local\Programs\Python\Python39\python.EXE
[Warn - 8:19:35 AM] Ignored rootPath C:\Users\MyPC of client "pyright"
[Info - 8:19:35 AM] Pyright language server 1.1.161 starting
[Info - 8:19:35 AM] Server root directory: C:\Users\MyPC\AppData\Local\coc\extensions\node_modules\coc-pyright\node_modules\pyright/dist/
[Info - 8:19:35 AM] No pyproject.toml file found.
[Info - 8:19:35 AM] Setting pythonPath for service "<default>": "C:\Users\MyPC\AppData\Local\Programs\Python\Python39\python.EXE"
[Warn - 8:19:35 AM] stubPath typings is not a valid directory.
[Info - 8:19:35 AM] Assuming Python version 3.9
[Info - 8:19:35 AM] Assuming Python platform Windows
[Info - 8:19:35 AM] Searching for source files
[Info - 8:19:35 AM] No source files found.
Here is my python folder:
However, when I import my module in the same directory:
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Import could not be resolved/could not be ... - Stack Overflow
Open the Command Palette ( Ctrl + Shift + P ), then select the Python: Select Interpreter. From the list, select the virtual...
Read more >Import could not be resolved [Pylance] : r/vscode - Reddit
Try to Reload Window. If the error still exists, check if you install the module in your selected interpreter environment.
Read more >ModuleNotFoundError: no module named Python Error [Fixed]
As I mentioned in the previous section, there are a couple of reasons a module may not be found. Here are some solutions....
Read more >Traps for the Unwary in Python's Import System
modules at the end as you should so tests don't influence each other. To save time you put custom exception classes in foo.py...
Read more >Documentation - Module Resolution - TypeScript
A relative import is resolved relative to the importing file and cannot resolve to an ambient module declaration. You should use relative imports...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The language server, here is Pyright, needs the workspace root to work, coc will try to detect the root by some patterns like
.git
,pyproject.toml
andb:coc_root_patterns
, that’s why you need to open vim in your project root.In a slightly different issue, where I have pip installed my own module with
pip install -e
, the python environment finds it when it runs, but pyright fails on linting. This might have something to do with the fact that in site-packages it includes a redirect to the parent directory (not in the workspace dir, because it doesn’t have to be via a pip install). The solution, which enables the python program to run and pyright to find the module, is to create a symbolic link in the workspace folder with the same name as the module, and point it to the original location… Hopefully saves someone time.Note: adding a pyrightconfig.json with extraPaths: [‘<path_to_module>’], does not work.