jedi-vim: sys.executable might be Vim itself with embedded Python (UnpicklingError)
(sorry for miss spellings, I’m french and I’ll try my best to explain my issue)
Issue
When I try to <c-space> or when jedi-vim want to help me, a new window of gvim pop-up with main.py oppened from jedi’s file instead of the list of propositions and sometimes, when I go back to the previews window, gvim stop working…
Steps to reproduce
here is my _vimrc ::
source $VIMRUNTIME/vimrc_example.vim
let python_highlight_all=1
syntax on
"Enable folding + space to fold
set foldmethod=indent
set foldlevel=99
nnoremap <space> za
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg1 = substitute(arg1, '!', '\!', 'g')
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg2 = substitute(arg2, '!', '\!', 'g')
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let arg3 = substitute(arg3, '!', '\!', 'g')
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
set nu
set guifont=Courier_new:h11
set encoding=utf-8
set nocompatible
color desert
filetype off
set rtp+=%USERPROFILE%/vim/bundle/Vundle.vim/
call vundle#begin('%USERPROFILE%/vim/bundle/')
Plugin 'vundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'itchyny/lightline.vim'
Plugin 'mattn/emmet-vim'
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'altercation/vim-colors-solarized'
Plugin 'jiangmiao/auto-pairs'
Plugin 'kien/rainbow_parentheses.vim'
Plugin 'vim-syntastic/syntastic'
Plugin 'nvie/vim-flake8'
Plugin 'tpope/vim-dispatch'
Plugin 'https://github.com/StanAngeloff/php.vim.git'
Plugin 'joonty/vim-phpqa'
Plugin 'davidhalter/jedi-vim'
call vundle#end()
filetype plugin indent on
"if has('gui_running')
" set background=dark
" colorscheme solarized
"else
" colorscheme zenburn
"endif
filetype plugin on
set omnifunc=syntaxcomplete#Complete
Output of “:verbose JediDebugInfo”
when I do this command, the same windows apear with
import sys
import os
def _get_paths():
# Get the path to jedi.
_d = os.path.dirname
_jedi_path = _d(_d(_d(_d(_d(__file__)))))
_parso_path = sys.argv[1]
# The paths are the directory that jedi and parso lie in.
return {'jedi': _jedi_path, 'parso': _parso_path}
# Remove the first entry, because it's simply a directory entry that equals
# this directory.
del sys.path[0]
if sys.version_info > (3, 4):
from importlib.machinery import PathFinder
class _ExactImporter(object):
def __init__(self, path_dct):
self._path_dct = path_dct
def find_module(self, fullname, path=None):
if path is None and fullname in self._path_dct:
p = self._path_dct[fullname]
loader = PathFinder.find_module(fullname, path=[p])
return loader
return None
# Try to import jedi/parso.
sys.meta_path.insert(0, _ExactImporter(_get_paths()))
from jedi.evaluate.compiled import subprocess # NOQA
sys.meta_path.pop(0)
else:
import imp
def load(name):
paths = list(_get_paths().values())
fp, pathname, description = imp.find_module(name, paths)
return imp.load_module(name, fp, pathname, description)
load('parso')
load('jedi')
from jedi.evaluate.compiled import subprocess # NOQA
# Retrieve the pickle protocol.
pickle_protocol = int(sys.argv[2])
# And finally start the client.
subprocess.Listener(pickle_protocol).listen()
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 83 (26 by maintainers)
Links to this issue
Commits related to this issue
- Check for specific Python versions first on unix, see davidhalter/jedi-vim#870 — committed to davidhalter/jedi by davidhalter 5 years ago
- Update submodule rplugin/python3/deoplete/vendored/jedi 2f86f54...0bf8a69 * rplugin/python3/deoplete/vendored/jedi 2f86f54...0bf8a69 (7): > v13.3 release notes > A small improvement f... — committed to blueyed/deoplete-jedi by blueyed 5 years ago
- [update to 0.13.3] Fix embedded Python with Jedi (see comments in source code), fixes davidhalter/jedi-vim#870 Dave Halter (9): setup.py was not executable in Python3.7 Improve an error m... — committed to clearlinux-pkgs/jedi by fenrus75 5 years ago
- Jedi #870 is fixed: disable workaround vim/vimrc: Disable but do not remove the workaround for https://github.com/davidhalter/jedi-vim/issues/870 now that it is closed. — committed to scrosland/dotfiles by scrosland 5 years ago
- Fix embedded Python with Jedi (see comments in source code), fixes davidhalter/jedi-vim#870 — committed to adefossez/jedi by davidhalter 5 years ago
- Check for specific Python versions first on unix, see davidhalter/jedi-vim#870 — committed to adefossez/jedi by davidhalter 5 years ago
- 0.17.0 (2020-04-14) +++++++++++++++++++ - Added ``Project`` support. This allows a user to specify which folders Jedi should work with. - Added support for Refactoring. The following refactorings h... — committed to NetBSD/pkgsrc by deleted user 4 years ago
put
py3 import os; sys.executable=os.path.join(sys.prefix, 'python.exe')into .vimrc or _vimrc file
This has already been discussed on the Vim mailing list and it’s not an issue with Vim but a peculiarity of Python on Windows: when a program is embedding Python,
sys.executablepoints to the executable of that program instead of the interpreter.I would if I were a user of jedi-vim but I am not.