I'm using coc-pyright
in Nvim and running into some issues.
Firstly, in Nvim, running :checkhealth
results in the following error message:
## Python 3 provider (optional)
42 - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
43 - ERROR: Python provider error:
44 - ADVICE:
45 - provider/pythonx: Could not load Python 3:
46 /home/<project path>/.venv/bin/python3 does not have the "neovim" module. :help provider-python
47 python3.7 not found in search path or not executable.
48 python3.6 not found in search path or not executable.
49 python3.5 not found in search path or not executable.
50 python3.4 not found in search path or not executable.
51 python3.3 not found in search path or not executable.
52 /home/<project path>/.venv/bin/python does not have the "neovim" module. :help provider-python
53 - INFO: Executable: Not found
This is fine, and makes perfect sense. Adding the pynvim
package (pip install pynvim
) will result in the following when using :checkhealth
:
# Python 3 provider (optional)
42 - INFO: `g:python3_host_prog` is not set. Searching for python3 in the environment.
43 - INFO: Multiple python3 executables found. Set `g:python3_host_prog` to avoid surprises.
44 - WARNING: Your virtualenv is not set up optimally.
45 - ADVICE:
46 - Create a virtualenv specifically for Neovim and use `g:python3_host_prog`. This will avoid the need to install the pynvim module in each virtualenv.
47 - INFO: $VIRTUAL_ENV matches executable
48 - INFO: Executable: /home/<project path>/.venv/bin/python3
49 - INFO: Other python executable: /usr/bin/python3
50 - INFO: Other python executable: /bin/python3
51 - INFO: Python version: 3.9.5
52 - INFO: pynvim version: 0.4.3
53 - OK: Latest pynvim is installed.
This too makes sense. Saves from installing globally. The issue I run into, however, is that this would require me enabling two separate virtual environments at the same time. One for pynvim
alone, the other for all local project dependencies, and I can't figure out how I'm supposed to do this.
If I enable the global, coc-pyright
can't find any local modules and will throw errors. If I enable the global, then nvim doesn't have pynvim
which it needs.
How are you supposed to do this?