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.

Python interpreter for jedi in neovim

See original GitHub issue

Issue

I use neovim and jedi to jump through my python source. Also I use pyenv tool to manage different python executable versions. My neovim python package is installed for python3.5 executable and neovim editor is bound to this executable as its python3_host_prog executable and jedi package is installed for system python2 executable.

" Python {{{
if filereadable(glob('~/.pyenv/versions/neovim3/bin/python'))
    let g:python3_host_prog = glob('~/.pyenv/versions/neovim3/bin/python')
endif
if filereadable(glob('~/.pyenv/versions/neovim36/bin/python'))
    let g:python3_host_prog = glob('~/.pyenv/versions/neovim36/bin/python')
endif
if filereadable(glob('~/.pyenv/versions/neovim2/bin/python'))
    let g:python_host_prog = glob('~/.pyenv/versions/neovim2/bin/python')
endif
" }}}
Output of the “JediDebugInfo” command (in a Python buffer)
Using Python version: 3
 - sys.version: 3.5.1 (default, Jun 21 2016, 19:49:53), [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
 - site module: /Users/friday/.pyenv/versions/3.5.1/lib/python3.5/site.py
Jedi path: /Users/friday/.config/nvim/plugged/jedi-vim/jedi/jedi/__init__.py
Jedi version: 0.9.0
jedi-vim git version: e66c2e1
jedi git submodule status:  995a6531225ba0b65e1ff863d97e5404d989047b jedi (v0.9.0-19-g995a653)

When I use another python executable, jedi-vim detects the virtualenv but uses the same python executable is before.

Why python from path is not used?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

5reactions
lithammercommented, Jan 13, 2017

I have this problem as well. The thing is, I want different Python interpreters to be used. Neovim should use whatever I have defined in g:python_host_prog (because that’s the one with the neovim package installed into it). But Jedi should just use the first interpreter found in $PATH so that it can autocomplete project/local dependencies. Alternative workarounds are:

  • Install neovim into every virtualenv/pyenv and omit g:python_host_prog and g:python3_host_prog from the .vimrc to force it use whatever is first in $PATH.
  • Create a mega virtualenv that has all the dependencies of every project you have and point g:python_host_prog to that.

Alternatively use YCM or deoplete.nvim+deoplete-jedi because they work correctly.

1reaction
yevhen-mcommented, Feb 19, 2017

@renstrom I use deoplete + deoplete-jedi and must say they work almost perfectly. But, I use jedi-vim’s goto feature. I use different python versions for my projects, and now I’ve found the way to make it work. I use exrc files, project-specific vim files. All I have to do is create a new virtualenv for a python version, install neovim package there, and redefine g:python_host_prog in project-specific .vimrc so it points to the correct python executable in this new env for this python version.

I suppose this may make your jedi-vim completion work as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Jedi — Jedi 0.18.2 documentation - Read the Docs
python interpreter. One with your custom ; $HOME/.pythonrc.py file and one that uses ; PYTHONSTARTUP .
Read more >
A Complete Guide to Neovim Configuration for Python ... - jdhao
In this post, I will give a detailed guide on how to install Neovim and configure it as an IDE-like environment for Python...
Read more >
How does neovim find the python interpreter? - Reddit
I'm having an issue that the interpreter located is 3.8, which is my system python. I have pyenv, which has 3.8 and 3.7,...
Read more >
jedi-vim - Vim Awesome
You can check this from within VIM using ``:python3 import sys; print(sys.version)`` (use ``:python`` for Python 2). Manual installation ---------------- ...
Read more >
how to change python interpreter used by jedi-vim
I was able to fix it myself by providing jedi-vim with the location of the packages in my anaconda folder using the $PYTHONPATH...
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