question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Pyright reportMissingImorts] and change python.pythonPath not worked

See original GitHub issue

pyright-issue when I import packages, there will be an error, so I checked the coc and pyright infos.

this is my coc-info:

## versions

vim version: NVIM v0.6.1
node version: v14.8.0
coc.nvim version: 0.0.80-1fffa716 2022-04-04 12:52:23 +0800
coc.nvim directory: C:\Users\AaronYoung\AppData\Local\nvim\plugged\coc.nvim
term: vtpcon
platform: win32

## Log of coc.nvim

2022-04-06T17:49:21.373 INFO (pid:4908) [services] - registered service "pyright"
2022-04-06T17:49:21.388 INFO (pid:4908) [services] - Pyright Server state change: stopped => starting
2022-04-06T17:49:21.408 INFO (pid:4908) [plugin] - coc.nvim initialized with node: v14.8.0 after 532ms
2022-04-06T17:49:21.892 INFO (pid:4908) [attach] - receive notification: highlight []
2022-04-06T17:49:22.571 INFO (pid:4908) [services] - Pyright Server state change: starting => running
2022-04-06T17:49:22.581 INFO (pid:4908) [services] - service pyright started

the output of :CocCommand pyright.version

[coc.nvim] coc-pyright 1.1.232 with Pyright 1.1.235

the output of :CocCommand workspace.showOutput Pyright

Workspace: d:\python
Using python from C:\0.my\software\Anaconda\Scripts\python.exe

[Info  - 下午5:39:52] Pyright language server 1.1.235 starting
[Info  - 下午5:39:52] Server root directory: C:\Users\AaronYoung\AppData\Local\coc\extensions\node_modules\coc-pyright\node_modules\pyright/dist/
[Info  - 下午5:39:52] No configuration file found.
[Info  - 下午5:39:52] No pyproject.toml file found.
[Info  - 下午5:39:52] Setting pythonPath for service "python": "C:\0.my\software\Anaconda\Scripts\python.exe"
[Warn  - 下午5:39:52] stubPath d:\python\typings is not a valid directory.
[Info  - 下午5:39:52] Unable to get Python version from interpreter
[Info  - 下午5:39:52] Assuming Python platform Windows
[Info  - 下午5:39:52] Searching for source files
[Info  - 下午5:39:59] Found 1486 source files

it can’t find the right python interpreter, my python path should be C:\0.my\software\Anaconda\python.exe but not C:\0.my\software\Anaconda\Scripts\python.exe. (not in Scripts folder) so I write it in coc-settings.json(:CocConfig):

        "python.pythonPath": "C:/0.my/software/Anaconda/python.exe"

but it does not work, the output of :CocCommand workspace.showOutput Pyright is still the same, the python path doesn’t change., the path is still C:\0.my\software\Anaconda\Scripts\python.exe:

Workspace: d:\python
Using python from C:\0.my\software\Anaconda\Scripts\python.exe

[Info  - 下午6:06:12] Pyright language server 1.1.235 starting
[Info  - 下午6:06:12] Server root directory: C:\Users\AaronYoung\AppData\Local\coc\extensions\node_modules\coc-pyright\node_modules\pyright/dist/
[Info  - 下午6:06:12] No configuration file found.
[Info  - 下午6:06:12] No pyproject.toml file found.
[Info  - 下午6:06:12] Setting pythonPath for service "python": "C:\0.my\software\Anaconda\Scripts\python.exe"
[Warn  - 下午6:06:12] stubPath d:\python\typings is not a valid directory.
[Info  - 下午6:06:12] Unable to get Python version from interpreter
[Info  - 下午6:06:12] Assuming Python platform Windows
[Info  - 下午6:06:12] Searching for source files
[Info  - 下午6:06:20] Found 1486 source files

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fannheywardcommented, Apr 11, 2022

why it doesn’t work even if I change the pythonPath in the config file coc-settings.json

coc-pyright will detect Python in current project from virtualenv/conda/pipenv/poetry etc. If none is found, coc-pyright will use pythonPath as fallback.

0reactions
fannheywardcommented, May 3, 2022

Try v1.1.243, should be fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

reportMissingImports reported even though python.venvPath ...
Pyright gives a reportMissingImports report for a module import even though I have python.venvPath set to the directory where the module can ...
Read more >
python - "Import could not be resolved" reported by Pyright
I work in Local Environment and I can solve this problem by going to Setting.json and search python analysis but I just addressed...
Read more >
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...
Read more >
https://raw.githubusercontent.com/microsoft/pyrigh...
If no paths are specified, pyright defaults to the directory that ... it is best not to specify this setting in the config...
Read more >
Python lsp (pyright) not detecting local imports from the same ...
So this was working perfectly fine before, but it fails to resolve local imports now. I'm on a Macbook. For eg, if my...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found