2

The issue is on Arch (1) & Debian Jessie (2) where:

1.

> uname -r
4.0.5-1-ARCH
> echo $PYTHONPATH
/usr/lib/python2.7/
  1. Debian Jessie is without the PYTHONPATH set.

My vim is compiled with python.

:python import sys; print(sys.version)
2.7.10 (default, May 26 2015, 04:16:29)
[GCC 5.1.0]

I tried the following Arch Linux packages:

> pacman -S python2-jedi vim-jedi

completion works on classes but not on the subclasses.

import os          # os is built-in library.
os.                # ycm does not complete members of this class.

I removed them and downloaded the git package.

> cd ~/.vim/bundle/jedi-vim/jedi/test/ && ./run.py
Summary: (0 fails of 962 tests) in 18.819s

> cd ../ && ./setup build && ./setup install

And again, completion works on classes but not on the subclasses.

My previous question that sent me to jedi-vim from Vim YouCompleteMe Python subclasses are not detected on TAB-completion in Arch Linux

Community
  • 1
  • 1
binarytrails
  • 516
  • 4
  • 14
  • Could you provide `:mes`, `:scriptnames`, `:set omnifunc` after using the completion once? BTW: jedi-vim and YCM are both using Jedi under the hood. – Dave Halter Jul 11 '15 at 18:21
  • Thank for your time. Yes, I'm aware that jedi-vim and YCM both rely on Jedi. I posted in both to gain visibility. Here is the output http://pastebin.com/raw.php?i=mk8gxDzb – binarytrails Jul 12 '15 at 02:57
  • Strange, my `:scriptnames` has quite a few more things of jedi-vim that are loaded, among them `jedi-vim/autoload/jedi.vim`, which should definitely be in there. – Dave Halter Jul 13 '15 at 22:47
  • I think it is loaded at 14:. Also, after one completion I have a different output. Look at 14, 25, 26, 28, 31 from my new output http://pastebin.com/raw.php?i=9mDXfbLM. Both of this outputs are from Debian Jessie. – binarytrails Jul 14 '15 at 03:01
  • Now I see. But `:messages` stays empty after one completion? – Dave Halter Jul 14 '15 at 12:12
  • @DaveHalter Yes. Out of curiosity, on which system are you running your vim with Jedi? – binarytrails Jul 15 '15 at 21:43
  • On Ubuntu. But I ran it on Debian a while ago. People I know run it on Arch, Windows and Mac and I'm pretty sure on a lot of other Linux Distros. – Dave Halter Jul 15 '15 at 22:43
  • @DaveHalter You seem to be the author of Jedi. How does the plugin reference the Python site-packages etc.? Is it possible that it is a referenced path issue? In this case, it would be great if it was possible to define it during the setup. – binarytrails Jul 16 '15 at 23:03
  • It takes the `sys.path`, as defined by Python itself. Maybe the `sys.path` has been modified in your case. – Dave Halter Jul 17 '15 at 11:55
  • 1
    @DaveHalter I just realized that it was due to my incomprehension. Check my answer below! – binarytrails Jul 22 '15 at 20:54
  • Awesome, thanks for the research! – Dave Halter Aug 08 '15 at 16:18

2 Answers2

1

I just realized that I did an error due to my incomprehension. I was trying to import the following way:

wrongway

Which was natural when I used ipython with tab completion like this:

ipython

That is a wrong way to import a module in a python script. This is the right way:

rightway

Finally, the Jedi-Vim plug-in works perfectly. In case of uncertainty related to unavailable imports you can verify your imports with:

:python import sys; print(sys.path)

And then add the missing directories during the run time to test if their absence was causing the issue.

:python import sys; sys.path.append("/path/to/dir")

In my case the os.py was located at /usr/lib/python2.7/.

I hope this clarifies this for the future Jedi-Vim users.

binarytrails
  • 516
  • 4
  • 14
0

Old question, but I've found an alternative to amending sys.path if you are using virtual environments.

You can instead create a .pth (https://docs.python.org/2/library/site.html) file in your <virtualenv>/lib/<python>/site-packages folder that points to the root of your source e.g. if my source was in /user/123/python-proj/source folder and my virtual env was in the /user/123/python-proj/venv folder

echo '/user/123/python-proj/source > /user/123/python-proj/venv/lib/python3.5/site-packages/my-source.pth'

Make sure you activate the virtual env first, then launch vim and jedi should be able to find your code.

user783836
  • 3,099
  • 2
  • 29
  • 34