Friday, October 7, 2022

[SOLVED] (Neo)vim python support and active virtualenv conflict

Issue

I've got ordinarily supported Python under Neovim

init.vim:

" Plug 'plytophogy/vim-virtualenv'

 if has('nvim')
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
 else
  Plug 'Shougo/deoplete.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
 endif
 Plug 'zchee/deoplete-jedi'
 Plug 'davidhalter/jedi-vim'

When I start nvim when some virtual environment is active, it begins with this error message

UltiSnips requires py >= 2.7 or py3
Press ENTER or type command to continue

then a lot more, of course.

Personally I am not surprised. Plugins' Python code should not be run inside a virtual environment which has nothing to do with it. Yet I have to. What can I do?

vim-virtualenv apparently does not have anything to do with this problem in any way. Does not address it, too.


Solution

See this documentation for Neovim providers:

PYTHON PROVIDER CONFIGURATION ~
                        *g:python_host_prog*
Command to start Python 2 (executable, not directory). Setting this makes
startup faster. Useful for working with virtualenvs.  >
    let g:python_host_prog  = '/path/to/python'
<
                        *g:python3_host_prog*
Command to start Python 3 (executable, not directory). Setting this makes
startup faster. Useful for working with virtualenvs.  >
    let g:python3_host_prog = '/path/to/python3'


Answered By - Hari Amoor
Answer Checked By - Terry (WPSolving Volunteer)