<p>我在Nvim中使用了<a href="https://github.com/fannheyward/coc-pyright" rel="nofollow noreferrer">^{<cd1>}</a>,遇到了一些问题</p>
<p>首先,在Nvim中,运行<code>:checkhealth</code>会导致以下错误消息:</p>
<pre><code>## 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
</code></pre>
<p>这很好,而且非常有意义。使用<code>:checkhealth</code>时,添加<code>pynvim</code>包(<code>pip install pynvim</code>)将导致以下结果:</p>
<pre><code># 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.
</code></pre>
<p>这也有道理。避免全局安装。然而,我遇到的问题是,这需要我同时启用两个独立的虚拟环境。一个单独用于<code>pynvim</code>,另一个用于所有本地项目依赖项,我不知道应该如何做到这一点</p>
<p>如果启用全局,则<code>coc-pyright</code>找不到任何本地模块,并将抛出错误。如果我启用了全局,那么nvim就没有它需要的<code>pynvim</code></p>
<p>你该怎么做</p>