jedi-vim: jedi-vim does not actually use virtualenv
Issue
It states in the documentation that it “Supports virtualenv”, but It does not work for me.
Steps to reproduce
I have a project directory and inside I have a venv folder that was created with:
virtualenv -p /usr/local/bin/python3 venv
I source this venv with the usual command:
source venv/bin/activate
I install some packages in this venv: hamcrest and requests
I start vim in this directory
result of :! python --version is Python 3.4.1
I go to a file in my project that uses either hamcrest or requests, I do <leader>d, it works, but when I check the path of the file it went to is actually on/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/hamcrest/__init__.py
I uninstall hamcrest from my system python 2.7.13
I start vim again and go to that file, do <leader>d:
“jedi-vim: Couldn’t find any definitions for this.”
My conclusion is that in reality jedi-vim does not actually use the virtual env…
Versions
- jedi-vim: no idea
- Vim version 8
- Python: 2.7, 3.4.1, 3.5.2
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 25
- Comments: 25 (9 by maintainers)
@xarthurx I use a simple hack to be able to get completions when changing the virtualenv inside vim. I do this by changing the
g:deoplete#sources#jedi#python_pathvariable each time that the virtual environment is changes viaVirtualEnvActivate(link to code). It is maybe not the best solution, but it works.ATM I use neovim with neovim (pep8 and yapf) python package(s) installed inside given virtual env.
With this configuration if I source my venv before opening neovim completion and doc are available from given virtual env.
I also use deoplete for completion and ale for syntax checking (both are async).
This setup is (at least for me) the perfect setup for python development using [neo]vim.
Check my .vimrc for configuration details
Let me know your through.
@skamsie @blueyed I found a simple workaround, assuming you use Python 3.5 or 2.7 on Linux Mint (can’t vouch for any other environment at this point):
I confirm that 3.6 does not work yet; David Halter has already confirmed Python 3.6 development is pending other changes to core Jedi.
Hope this helps!
Thanks for pointing to that. As a note for posterity, it seems there was a typo and the environment variable is actually called
VIRTUAL_ENV.Virtualenvs are now supported very well. If you don’t like the current support, we can discuss it. However I’m pretty sure there’s not a lot that can be improved (there’s also no open bugs in Jedi).
Jedi’s support for virtualenvs is currently very marginal. IMO we still have to wait for davidhalter/jedi#385. Sorry, but I really don’t like venv support either. However it will get better and I’m finally starting to have time for it.