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

How to enable Python 3 support without compiling Python 3 within Vim? #536

Closed
wolph opened this issue Jan 24, 2016 · 5 comments
Closed

How to enable Python 3 support without compiling Python 3 within Vim? #536

wolph opened this issue Jan 24, 2016 · 5 comments

Comments

@wolph
Copy link
Contributor

wolph commented Jan 24, 2016

About half of the time I develop using Python 2 and the other half of the time I develop using Python 3. But it seems that Jedi is unable to understand that even though /usr/bin/env python will return in a Python 3 interpreter within those Python 3 virtualenvs and always goes to Python 2 instead.
The result is that when I do a <leader>g I go to the Python 2 version instead of the Python 3 version which can be quite different.

I've tried forcing Jedi to use Python 3 using this setting:

let g:jedi#force_py_version = 3

But that results in:

Error: jedi-vim failed to initialize Python: Could not setup g:jedi#force_py_version: jedi#setup_py_version: Vim(py3file):E319: Sorry, the command is not available in this version: py3file ~/.vim/bun
dle/jedi-vim/initialize.py (in function jedi#init_python[3]..<SNR>98_init_python, line 6)```

Since I run Vim through homebrew (as most OS X developers would), I unfortunately can't build both Python 2 and Python 3 support into Vim. The install options for Vim through homebrew:

--disable-nls
    Build vim without National Language Support (translated messages, keymaps)
--override-system-vi
    Override system vi
--with-client-server
    Enable client/server mode
--with-lua
    Build vim with lua support
--with-luajit
    Build with luajit support
--with-mzscheme
    Build vim with mzscheme support
--with-python3
    Build vim with python3 instead of python[2] support
--with-tcl
    Build vim with tcl support
--without-perl
    Build vim without perl support
--without-python
    Build vim without python support
--without-ruby
    Build vim without ruby support
--HEAD
    Install HEAD version

Is there any other way to fix this?

Thinking about it, even being able to modify the search path for GotoDefinition would probably fix the issue as well but I don't see an option similar to that anywhere in the docs either.

@davidhalter
Copy link
Owner

@wolph There's not really a solution. The only thing we can do is to finally implement davidhalter/jedi#385. With that it would be really easy to have multiple versions working. But without a client/server architecture it's not possible.

@blueyed
Copy link
Collaborator

blueyed commented Jan 25, 2016

It works quite good for me using Neovim, which supports Python 2 and 3 in parallel better than Vim.
But then I'm mostly working on Python 3 anyway.

What is <leader>g doing in your config?
Is it based on virtualenvs?

@wolph
Copy link
Contributor Author

wolph commented Jan 25, 2016

@davidhalter: in that case, is there any way to influence the module search path? If I could simply insert the path before the regular paths it would work as well.

@davidhalter
Copy link
Owner

@wolph You can do that by modifying the sys.path itself (in pretty much any Jedi version, but the dev/linter heads). If you're on a newer version you have to modify jedi-vim and provide the sys_path argument in jedi.Script. There's no support in jedi-vim itself, because I'd rather solve the async server issue first (which is connected with this).

@wolph
Copy link
Contributor Author

wolph commented Jan 25, 2016

Ok, I'll give that a try. Thank you so much for the help :)

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

3 participants