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

Add virtualenv support #31

Closed
estin opened this issue Oct 27, 2012 · 10 comments
Closed

Add virtualenv support #31

estin opened this issue Oct 27, 2012 · 10 comments
Labels

Comments

@estin
Copy link

estin commented Oct 27, 2012

On switching virtualenv/interpreter do reinitialize python stuff.

When I start vim, jedi use system python interpreter

But I used VirutalEnv vim plugin for switching per project.
I have many projects in tabs for one vim instance.

To solve this issue I wrote simple function for reimporting jedi lib and jedi_vim files in new virtualenv

Sorry for my poor English (

@Shougo
Copy link

Shougo commented Oct 27, 2012

I think it is impossible.
Because, jedi-vim uses python interface. The python interface uses only one interpreter.

@strycore
Copy link
Contributor

I have this in my vimrc, I don't think you need more for virtualenv support for any plugin:

" Add the virtualenv's site-packages to vim path
if has('python')
py << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
    project_base_dir = os.environ['VIRTUAL_ENV']
    sys.path.insert(0, project_base_dir)
    activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
    execfile(activate_this, dict(__file__=activate_this))
EOF
endif

@dbrgn
Copy link
Collaborator

dbrgn commented Oct 28, 2012

Related to davidhalter/jedi#36.

The approach by @strycore looks pretty good to me. There are other ways to check whether the current interpreter session is a virtualenv, but that won't help here as we have to detect a virtualenv from outside.

The environment variable is not 100% reliable, but probably the best solution we can find.

@strycore It appears that the vim import is unnecessary, am I right? Or does it have some side effects?

@davidhalter
Copy link
Owner

davidhalter/jedi@580a4f4

Please try and test, I don't really use virtualenv.

@dbrgn
Copy link
Collaborator

dbrgn commented Nov 18, 2012

@davidhalter You don't? Are you crazy? :)

I'll test this tonight, thanks.

@davidhalter
Copy link
Owner

@gwrtheyrn Crazy? Lazy would be the right word :-)

@dbrgn
Copy link
Collaborator

dbrgn commented Nov 30, 2012

@davidhalter i'm not @gwrtheyrn anymore, so i guess i don't have to deal with this :p

(no, i'll try to test this tonight, really.)

@dbrgn
Copy link
Collaborator

dbrgn commented Dec 2, 2012

Seems to work OK :) Thanks!

@davidhalter
Copy link
Owner

virtualenv support is now being mentioned here:
https://github.com/davidhalter/jedi#support

douglarek added a commit to douglarek/.vim.d that referenced this issue Nov 4, 2014
cometsong added a commit to cometsong/vimfiles that referenced this issue Mar 19, 2015
@cmcginty
Copy link

See #685

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

No branches or pull requests

6 participants