sys.executable might be Vim itself with embedded Python (UnpicklingError)
See original GitHub issue(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()
Issue Analytics
- State:
- Created 5 years ago
- Comments:83 (26 by maintainers)
Top Results From Across the Web
[Bug] Python sys.executable command returns Vim path, not ...
Hello. I've stumbled on a problem that sys.executable python command inside Vim returns a Vim path, when it should return a Python path....
Read more >Solved: RemotePlugin Python 3.8 included Runtime limitation
My guess is that this has to do how the runtime is called/embedded within the remotepluginmodule. Does anyone with some knowledge around the ......
Read more >かしゅー on Twitter: "Issueここにあったんだねー / "sys.executable ...
sys.executable might be Vim itself with embedded Python (UnpicklingError) · Issue #870 · davidhal... (sorry for miss spellings, I'm french and I'll try...
Read more >2010-January.txt - Python mailing list
"default encoding": what is it? ascii, utf-8 as almost implied, something in sys module (if so, please specify). A cleaner API would have...
Read more >Programming in Python 3
Python can be used to program in procedural, object-oriented, ... Many powerful plain text editors, such as Vim and Emacs, come with built-in....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.executable
points to the executable of that program instead of the interpreter.I would if I were a user of jedi-vim but I am not.