You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So the issue is when creating a virtual enviorment with python 3.6 and installing any 3rd party library, jedi vim's omni completion does not show any results.
Steps to reproduce
Make sure you have virtual enviorment activated and with python 3.6
pip install django
open a python file vim a.py
start typing from django. and after the '.' activate omni completion. It should say no results found.
Solution
Below you can see the output of redir @+> | silent verb JediDebugInfo | redir END
So let me walk you through the solution I found. Actually there a couple of walkarounds I will show you because I believe this problem is really hard to google (at least for me it was) and is kinda tricky to find.
Let's begin. Open up a .py file and enter the command JediDebugInfo. You will see information about jedi vim. The part we are interested in is sys_path. If you look closely at the virtual enviorment path you will notice something like this /username/.virtualenvs/name-of-env/lib/**python3.5**/site-packages. Now if you go to the lib folder of the enviorment you will notice that the next folder is named python3.6 not python3.5. So it cannot find the site packages of the enviorment therefore omni completion does not work.
Now for the impatient, the easy solution is just to rename the folder from python3.6 to python3.5. Everything will work just fine. The problem with that is that you need to do this for every virtual env you make with python3.6 if you want omni completion.
This solution was not good enough for me so I went on digging. It is obvious that if I make my env with python 3.6 and the sys_path contains python 3.5 it means that something is generating this path and is hard coded somewhere(thank god it's not binary).Now you hit another major problem because you can't google that as well. Here comes the part you'll thank me for - The method that is responsible for generating the sys_path under virtual env is located in ~/.vim/bundle/jedi-vim/jedi/jedi/evaluate/sys_path.py line 15. Now you can write you custom code to detect python 3.6 envs and site-packages folders. Add the paths you want as a list of strings on line 24 where the return statement is.
However, both solutions are just walkarounds. The problem originates because jedi-vim uses the vim default intepreter which if compiled with +python3 is python 3.5.2.
Hope this get fixed and someone who has had this problem finds my solutions useful :)
Output of “:verbose JediDebugInfo”
Jedi-vim debug information
Using Python version: 3
sys.version: 3.5.3 (default, Jan 19 2017, 14:11:04), [GCC 6.3.0 20170118]
site module: /usr/lib/python3.5/site.py
Jedi path: /root/.vim/bundle/jedi-vim/jedi/jedi/__init__.py
g:jedi#force_py_version = 3 (default: 'auto')
g:jedi#popup_select_first = 0 (default: 1)
g:jedi#popup_on_dot = 0 (default: 1)
g:jedi#usages_command = '<leader>z' (default: '<leader>n')
omnifunc=jedi#completions
Last set from ~/.vimrc
completeopt=longest,menuone
Last set from ~/.vimrc
Thanks.
Being less strict in this regard was suggested for Jedi in davidhalter/jedi#829 - but closed for now. You can use the patch from there though for a more generic solution.
I see that it is more annoying with Vim, where the Python library is more static, whereas Neovim can use python instead.
Issue
Some prerequisites:
So the issue is when creating a virtual enviorment with python 3.6 and installing any 3rd party library, jedi vim's omni completion does not show any results.
Steps to reproduce
pip install django
vim a.py
from django.
and after the '.' activate omni completion. It should say no results found.Solution
Below you can see the output of
redir @+> | silent verb JediDebugInfo | redir END
So let me walk you through the solution I found. Actually there a couple of walkarounds I will show you because I believe this problem is really hard to google (at least for me it was) and is kinda tricky to find.
Let's begin. Open up a .py file and enter the command JediDebugInfo. You will see information about jedi vim. The part we are interested in is sys_path. If you look closely at the virtual enviorment path you will notice something like this
/username/.virtualenvs/name-of-env/lib/**python3.5**/site-packages
. Now if you go to the lib folder of the enviorment you will notice that the next folder is named python3.6 not python3.5. So it cannot find the site packages of the enviorment therefore omni completion does not work.Now for the impatient, the easy solution is just to rename the folder from python3.6 to python3.5. Everything will work just fine. The problem with that is that you need to do this for every virtual env you make with python3.6 if you want omni completion.
This solution was not good enough for me so I went on digging. It is obvious that if I make my env with python 3.6 and the sys_path contains python 3.5 it means that something is generating this path and is hard coded somewhere(thank god it's not binary).Now you hit another major problem because you can't google that as well. Here comes the part you'll thank me for - The method that is responsible for generating the sys_path under virtual env is located in
~/.vim/bundle/jedi-vim/jedi/jedi/evaluate/sys_path.py
line 15. Now you can write you custom code to detect python 3.6 envs and site-packages folders. Add the paths you want as a list of strings on line 24 where the return statement is.However, both solutions are just walkarounds. The problem originates because jedi-vim uses the vim default intepreter which if compiled with +python3 is python 3.5.2.
Hope this get fixed and someone who has had this problem finds my solutions useful :)
Output of “:verbose JediDebugInfo”
Jedi-vim debug information
Using Python version: 3
3.5.3 (default, Jan 19 2017, 14:11:04), [GCC 6.3.0 20170118]
/usr/lib/python3.5/site.py
Jedi path:
/root/.vim/bundle/jedi-vim/jedi/jedi/__init__.py
/root/.virtualenvs/testing-autocomplete-for36/lib/python3.5/site-packages
/root/.vim/bundle/jedi-vim
/root/.virtualenvs/testing-autocomplete-for36/lib/python3.5/site-packages
/usr/local/lib/python3.5/dist-packages/setuptools-18.1-py3.5.egg
/usr/local/bin/python3.6
/usr/lib/python35.zip
/usr/lib/python3.5
/usr/lib/python3.5/plat-x86_64-linux-gnu
/usr/lib/python3.5/lib-dynload
/usr/lib/python3.5/site-packages
/usr/local/lib/python3.5/dist-packages
/usr/lib/python3/dist-packages
_vim_path_
/root/.vim/bundle/vim-virtualenv/autoload
/root/.virtualenvs/testing-autocomplete-for36/lib/python3.6/site-packages
Settings
:version
:messages
:scriptnames
The text was updated successfully, but these errors were encountered: