I have Anaconda (including python3.5.2), VIM (7.4) and Jedi-VIM installed on my system. There was also a python installed on the linux system by default.

The autocompletion is working on base packages, at least. But for packages like numpy (which was included in Anaconda) the completion is not working.

By using the following command in VIM:

:py3 import sys; print(sys.path)


This indicates to me that the Anaconda-python interpreter and the packages are never been used by jedi-vim.

$which python

How can I get jedi-vim to use also the path of anaconda python for getting package autocompletion?


I was able to fix it myself by providing jedi-vim with the location of the packages in my anaconda folder using the $PYTHONPATH variable as follows:

export PYTHONPATH=$PYTHONPATH:/home/user1/anaconda3/lib/python3.5/site-packages

Thanks to all!

Or Add following line in ~/.bash_profile

export PYTHONPATH=$PYTHONPATH:/home/user1/anaconda3/lib/python3.5/site-packages

| improve this answer | |
  • Thanks! Adding export PYTHONPATH="/home/user-name/anaconda3/lib/python3.5/site-packages":$PYTHONPATH to my ~/.zshrc got jedi-vim to work correctly with anaconda. – joelostblom Sep 10 '16 at 18:22
  • 5
    You should not do that. That might lead to a SEGFAULT. It's dangerous. – Dave Halter Sep 11 '16 at 6:16
  • @DaveHalter When you said it might lead to a SEGFAULT, were you referring to what was proposed in the answer or what was proposed in the previous comment? Also, do you know why a SEGFAULT might occur? – Jack Kinsella Jun 28 '19 at 12:46
  • 1
    @JackKinsella Python versions need to match, otherwise when compiled modules get imported you load different versions. However I have updated my answer below. There are now environments in Jedi, which make this all easily possible. – Dave Halter Jul 9 '19 at 8:07

You can't. The :python and :python3 commands always use the compiled-in interpreters. If you have a recent version of Vim with python and / or python3 loaded dynamically (see :h python-dynamic) you can use pythondll and pythonthreedll to load different interpreters, but replacing CPython by Anaconda is IMO asking for segfaults (provided that Vim accepts it at all, that is).

| improve this answer | |

2018+ Jedi Versions

You can just use :let jedi#force_py_version=3.8 if you want to switch to the latest Python version, for example. Unfortunately there is no environment listing in jedi-vim, yet. We need to build that (it is available in Jedi, though).

Old Answer

Basically the only thing you can do currently is to compile VIM with Python 3.5 support. That's probably a stupid idea, but it works.

Otherwise there will be support for cross Python versions, with https://github.com/davidhalter/jedi/issues/385.

Note that it might be possible to modify the Python PATH, but that might lead to a SEGFAULT and to other unwanted behavior, because you're basically allowing Jedi to run binary code from another Python version (Yes it actually happens).

| improve this answer | |

You could compile vim with anaconda: I did ./configure --with-features=huge --enable-pythoninterp --with-python-config-dir=~/anaconda/lib/python2.7/config/, I remember that I did similar tests afterwards and :py import sys; print sys.path was giving me correct results.

Based on the web search you could perhaps do something like this (ex. for 3.4):

./configure --enable-python3interp --with-features=huge --with-python3-config-dir=~/anaconda/lib/python3.4/config-3.4m-x86_64-linux-gnu

| improve this answer | |

David has a valid point about intermingling Vim with different flavors of Python and if hard coding PYTHONPATH to Anaconda Python in .profile/.bashrc really does lead to SEG 11 could one use a shell alias.

alias vim3='PYTHONPATH=/usr/lib/Anaonda/.../site-packages vim'

Perhaps this work-around will suffice.

| improve this answer | |

I'm using 32bit vim for compatibility with other extensions, but the 64 bit python is first on my PATH for other reasons. Hence I installed the 32 bit python using conda via:

conda create -n py27_32bit python=2.7
activate py27_32bit
pip install jedi

and added this to my .vimrc:

if has('win32')&& isdirectory('C:/Users/USER/AppData/Local/Continuum/anaconda2/envs/py27_32bit/')
    let $PATH = 'C:/Users/USER/AppData/Local/Continuum/anaconda2/envs/py27_32bit/;
                \C:/Users/USER/AppData/Local/Continuum/anaconda2/envs/py27_32bit/lib/;' . $PATH
    let $PYTHONPATH = 'C:/Users/USER/AppData/Local/Continuum/anaconda2/envs/py27_32bit/;

where C:/Users/USER/AppData/Local/Continuum/anaconda2 is the result of calling conda info --base

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.