I am using python 3.4.3 in virtualenv. While opening a python file I get these errors.
"asynctest.py" [noeol] 24L, 454C
Error detected while processing function provider#python#Call:
line 1:
Exception('no request handler registered for "python_execute_file"',)
Press ENTER or type command to continue
If I disable the jedi plugin these errors go away. Also in python 2 these errors dont pop up. Any idea what can be done to fix it ?
let g:jedi#force_py_version=3
or
call jedi#force_py_version(3)
I tried them and got further errors. I can barely edit the file
Error detected while processing CursorMovedI Auto commands for "<buffer=1>":
E319: Sorry, the command is not available in this version: python3 jedi_vim.show_call
_signatures()
Do you have installed jedi module in Python3 environment?
yupp
Vim compiled with +python and +python3?
I am using neovim and it does not have those options. I will try it out on regular vim and let u know
It's seems Neovim issue
https://github.com/neovim/neovim/issues/1829
Python (3) support has been improved in Neovim by now.
Additionally https://github.com/davidhalter/jedi-vim/pull/387 is meant to enhance jedi-vim for Neovim.
Still can't get it working with python3 virtualenv. Tried on vim 7.3 and self-compiled vim 7.4.712 with +python3 flag. Anything work as expected with python2 virtualelenvs.
When I trying to set python version manually with call jedi#force_py_version(3), I getting segfault :(
Vim: Caught deadly signal ABRT
Mac OS X 10.10
@ssbb
Then likely your Python / Vim combo is screwed up. Does :py3 print(1) work?
I recommend using pyenv for managing multiple Python versions btw.
And Neovim has good support for both Python 2 and 3 now.
Hmm, it's crashed on print too. Thanks, I will try pyenv :)
Looks like you have some plugins with python 2.
I'm going to close this one. The neovim support has been improved. I will reopen if it's still an issue. @ssbb seems to have a different issue and you can commenting here.
Fixed already. Just installed python 3.4.3 with pyenv and recompiled macvim with it. :py3 print(1) still not working (I set correct LDFLAGS on configure stage):
E370: Could not load library libpython3.4m.dylib
E263: Sorry, this command is disabled, the Python library could not be loaded.
But all jedi features works like a charm. Thanks!
not sure if this will help anyone, here is my way around this.
1) I have VIM with following flags, was not able to find those for RHEL7 had to download the srpm and recompile myself. nether the less ...
[vmindru@vmutil python]$ vim --version | grep -io python.......
python/dyn
python3/dyn
[vmindru@vmutil python]$
2) the problem now is that vim will decide what to load python or python3 depending on which is called first. e.g. if you start a fresh vim session and do python then it loads python2 if you do python3 or py3 it loads python3 and afaik this can not be changed at runtime
3) the solution have this lines in your .vimrc at the very first line even before pathogen#infect() if you use it.
" ESTIMATE PYTHON VERSION, BASED ON THIS WE WILL SIMPLY CALL PY or PY3
" this will decide what version of pyton VIM will load
" note +python/dyn and +python3/dyn has to be loaded
let py_version = system('python -V 2>&1 | grep -Po "(?<=Python )[2|3]"')
if py_version == 2
python pass
elseif py_version == 3
python3 pass
else
python pass
endif
4) the result vim will load proper python based on your active virtualenv and your active python command.
@vmindru
Thanks for sharing.
It will slowdown your Vim startup though.
I recommend to use Neovim instead in general, and in this particular case you are able to configure the plugins usually instead (jedi-vim (g:jedi#force_py_version), UltiSnips etc).
If you want to keep this method, see how jedi-vim does it: https://github.com/davidhalter/jedi-vim/blob/7ddc50829eaa8350aa2bd60f4bb04e6620329b4f/autoload/jedi.vim#L76-L78:
" Get default python version from interpreter in $PATH.
let s:def_py = system('python -c '.shellescape('import sys; sys.stdout.write(str(sys.version_info[0]))'))
if v:shell_error != 0 || !len(s:def_py)
if !exists('g:jedi#squelch_py_warning')
echohl WarningMsg
echom 'Warning: jedi-vim failed to get Python version from sys.version_info: ' . s:def_py
echom 'Falling back to version 2.'
echohl None
endif
let s:def_py = 2
elseif &verbose
echom 'jedi-vim: auto-detected Python: '.s:def_py
endif
And you should also set g:jedi#force_py_version then.
Related: https://github.com/davidhalter/jedi-vim/pull/674.
Most helpful comment
let g:jedi#force_py_version=3
or
call jedi#force_py_version(3)