Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocompletion in virtualenv #379

Closed
eronde opened this issue Mar 30, 2015 · 13 comments
Closed

Autocompletion in virtualenv #379

eronde opened this issue Mar 30, 2015 · 13 comments

Comments

@eronde
Copy link

eronde commented Mar 30, 2015

Hi everyone,

I've installed virtualenv and vim-jedi and I like to know if it's possible to get auto completion and doc of installed modules in virtualenv.

For example when I install sqlalchemy in an virtualenv I can't get no docs or auto completion of sqlalchemy in vim.

@davidhalter
Copy link
Owner

It should work if you activate the virtualenv before opening the vim session and the python version matches. Also use the latest dev branch of Jedi.

@eronde
Copy link
Author

eronde commented Mar 31, 2015

Thnx for your reply.

I've tested it in the following setting:

(jedi-vim) master branch
#virtualenv, pip install virtualenv
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/project/python
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv
alias mkpro2="mkproject -p /usr/bin/python"
alias mkpro3="mkproject -p /usr/bin/python3"
source /usr/bin/virtualenvwrapper.sh

Made two projects:
mkproject -p /usr/bin/python3 test3
mkproject -p /usr/bin/python test2

workon test3
pip install peewee
pip install sqlalchemy
vim test.py
from peewee import *

If I put the cursor on peewee and I press 'K' It should display the docs of peewee, but it's says that there are no docs. Also when press '' it should display the completions of the imported modules.

The strange thing is when I import os or time, jedi-vim works great :)

I've tested it with test2 and test3.

I've tried to clone the dev branch of jedi-vim ( git clone --branch dev https://github.com/davidhalter/jedi-vim.git), but I get the following errors:
Error detected while processing /home/eric/.vim/bundle/jedi-vim/autoload/jedi.vim:
line 347:
Traceback (most recent call last):
File "", line 1, in
File "/home/eric/.vim/bundle/jedi-vim/initialize.py", line 24, in
vim.command('echoerr "Please install Jedi if you want to use jedi_vim."')
vim.error: Vim(echoerr):Please install Jedi if you want to use jedi_vim.
E171: Missing :endif
Error detected while processing /home/eric/.vim/bundle/jedi-vim/plugin/jedi.vim:
line 8:
E121: Undefined variable: g:jedi#auto_vim_configuration
E171: Missing :endif

@davidhalter
Copy link
Owner

Can you tell me what commit of jedi-vim you are using?

@eronde
Copy link
Author

eronde commented Apr 2, 2015

The last commit of the master branch:
commit d65c35a
Author: Dave Halter davidhalter88@gmail.com
Date: Tue Mar 31 00:54:58 2015 +0200

Problem with multi definitions tokenize tests. Jedi behaves different now, therefore I have disabled the tests. Once we find another example where it actually makes sense to test it, we can reenable the tests.

The last commit of the dev branch:
commit 69160c3
Author: Dave Halter davidhalter88@gmail.com
Date: Thu Mar 26 15:06:25 2015 +0100

Matching fat symbols (current params) in a better way.

@davidhalter
Copy link
Owner

What's your vim :ver?
On which Python version did you install Jedi?
Does jedi-vim work if you're not using virtualenvs?

@eronde
Copy link
Author

eronde commented Apr 2, 2015

I think there is a conflict between 2 versions:

Vim is compiled with python 2 and jedi is installed on python 3.4.

:python print sys.path (python, with and without virtualenv)
['/home/eric/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/bottle', '/home/eric/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/frozendict', '/home/eric/.vim/bundle/YouCompleteMe/third_party/ycmd/
third_party/jedi', '/home/eric/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests', '/home/eric/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/OmniSharpServer', '/home/eric/.vim/bundle/YouCom
pleteMe/third_party/ycmd/third_party/waitress', '/home/eric/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh', '/home/eric/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/argparse', '/home/eric/.v
im/bundle/YouCompleteMe/third_party/retries', '/home/eric/.vim/bundle/YouCompleteMe/third_party/requests', '/home/eric/.vim/bundle/YouCompleteMe/third_party/requests-futures', '/home/eric/.vim/bundle/YouCompleteM
e/third_party/pythonfutures', '/home/eric/.vim/bundle/YouCompleteMe/third_party/ycmd', '/home/eric/.vim/bundle/YouCompleteMe/autoload/../third_party/ycmd', '/home/eric/.vim/bundle/YouCompleteMe/autoload/../python
', '/home/eric/.vim/bundle/jedi-vim', '/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload',
'/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/gtk-2.0', '_vim_path_']

If I compile vim with python3 support and I run :python3 print (sys.path) I'm getting:
'/home/eric/.vim/bundle/jedi-vim', '/usr/lib/python3.4','/usr/lib/python3.4/site-packages','vim_path']

Any suggestions.

@davidhalter
Copy link
Owner

Hmm I'm also a bit afraid that ycm and jedi-vim might conflict. You don't need both.

@eronde
Copy link
Author

eronde commented Apr 6, 2015

Just removed ycm to see if it makes any differences, but no luck :|.

A few questions to see if it's not a config problem:
Does it matter if vim is compiled with just python2 compatibility?
Do I need config vim-jedi python library path so it can find the right libraries?

@davidhalter
Copy link
Owner

There's currently a PR davidhalter/jedi#562 about virtualenv that I intend to merge. Since I'm going to release very soon, let's just wait for that to happen.

I'm pretty sure you're just messing something up. VIRTUALENV support in VIM is not very good, to be honest it's very bad. emacs-jedi for example built a lot of stuff around Jedi to actually make it work. We have to improve quite a few things, before we can actually make it work well. I guess especially davidhalter/jedi#385 would help.

@eronde
Copy link
Author

eronde commented Apr 9, 2015

Thnx, I'll wait for the next release. Thanks for your time :)

@eronde eronde closed this as completed Apr 9, 2015
@davidhalter davidhalter reopened this Apr 9, 2015
@davidhalter
Copy link
Owner

Hmm I'm not sure if that PR will get into Jedi at the right time and even if I'm not sure if that will improve virtualenv support by a lot. So I'm reopening.

@eronde
Copy link
Author

eronde commented Apr 9, 2015

I've reinstalled all the plugins I'm using to see if it make a difference and now it include the site-packages of a virtualenv lib in the sys path. The only problem is that it include just 2.7 libs and not > 2.7

@davidhalter
Copy link
Owner

That's intentional. I've talked about this times and times again. As long as there's no mechanism to recover from segfaults (via multiprocessing or something similar), this will not happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants