neovim / pynvim

Python client and plugin host for Nvim
http://pynvim.readthedocs.io/en/latest/
Apache License 2.0
1.51k stars 118 forks source link

Is it possible to install in root environment once and then use pynvim in every virtualenv without install again? #498

Closed oakmegaeddie closed 2 years ago

oakmegaeddie commented 2 years ago

Currently I need to install pynvim every time I create a new virtualenv, is it possible to install it in root environment once and then I can use pynvim in every virtualenv?

justinmk commented 2 years ago

:help g:python3_host_prog

oakmegaeddie commented 2 years ago

Here's the solution found in :help g:python3_host_prog

If you plan to use per-project virtualenvs often, you should assign one virtualenv for Neovim and hard-code the interpreter path via g:python3_host_prog so that the "pynvim" package is not required for each virtualenv.

Example using pyenv:

    pyenv install 3.4.4
    pyenv virtualenv 3.4.4 py3nvim
    pyenv activate py3nvim
    python3 -m pip install pynvim
    pyenv which python  # Note the path

The last command reports the interpreter path, add it to your init.vim:

    let g:python3_host_prog = '/path/to/py3nvim/bin/python'

See also: https://github.com/zchee/deoplete-jedi/wiki/Setting-up-Python-for-Neovim