jedi-vim: UnpicklingError when jedi-vim tries to get vim version info

Issue

When I try to run a jedi command (e.g. <leader>d), I just get a stack trace. The most relevant line seems to be:

jedi.api.environment.InvalidPythonEnvironment: Could not get version information for '/usr/local/bin/vim': UnpicklingError("invalid load key, '3'.")

Full stack trace:

Traceback (most recent call last):
  File "/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi/jedi/api/environment.py", line 74, in _get_subprocess
    info = self._subprocess._send(None, _get_info)
  File "/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi/jedi/evaluate/compiled/subprocess/__init__.py", line 242, in _send
    is_exception, traceback, result = pickle_load(self._process.stdout)
  File "/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi/jedi/_compatibility.py", line 464, in pickle_load
    return pickle.load(file, encoding='bytes')
_pickle.UnpicklingError: invalid load key, '3'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi_vim.py", line 140, in wrapper
    return func(*args, **kwargs)
  File "/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi_vim.py", line 220, in get_script
    environment=get_environment(),
  File "/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi/jedi/api/__init__.py", line 108, in __init__
    project, environment=environment, script_path=self.path
  File "/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi/jedi/evaluate/__init__.py", line 94, in __init__
    self.compiled_subprocess = environment.get_evaluator_subprocess(self)
  File "/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi/jedi/api/environment.py", line 113, in get_evaluator_subprocess
    return EvaluatorSubprocess(evaluator, self._get_subprocess())
  File "/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi/jedi/api/environment.py", line 79, in _get_subprocess
    exc))
jedi.api.environment.InvalidPythonEnvironment: Could not get version information for '/usr/local/bin/vim': UnpicklingError("invalid load key, '3'.")
Traceback (most recent call last):
  File "/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi_vim.py", line 140, in wrapper
    return func(*args, **kwargs)
  File "/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi_vim.py", line 302, in goto
    definitions = script.goto_assignments(follow_imports=True)
AttributeError: 'NoneType' object has no attribute 'goto_assignments'

Steps to reproduce

Load a python script Move cursor over an identifier do \d

set nocompatible

let script_dir = fnamemodify(expand('<sfile>'), ':h')
let &runtimepath .= ','.script_dir.','.script_dir.'/after'

" Put your config changes here.
" let g:jedi#show_call_signatures=1

syntax on
filetype plugin indent on

minimal.vimrc:

set nocompatible

let script_dir = fnamemodify(expand('<sfile>'), ':h')
let &runtimepath .= ','.script_dir.','.script_dir.'/after'

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'gmarik/Vundle.vim'                "required
Plugin 'davidhalter/jedi-vim'

call vundle#end()            " required

" Put your config changes here.
let g:jedi#show_call_signatures=1

syntax on
filetype plugin indent on

Jedi-vim debug information

jedi-vim version
  • jedi-vim git version: 0.9.0-61-g2f65c63-dirty
  • jedi git submodule status: bd1010bbd2693f189ff780eb21fc4294071cb280 pythonx/jedi (v0.13.1)
  • parso git submodule status: 930ec08ab0cd77aae07e24aa78f9c5119be216bb pythonx/parso (v0.3.1-7-g930ec08)
Global Python

Using Python version 3 to access Jedi.

  • global sys.version: 3.7.1 (default, Nov 6 2018, 18:49:54), [Clang 9.0.0 (clang-900.0.39.2)]
  • global site module: /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site.py
Jedi
  • path: /Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi/jedi/__init__.py
  • version: 0.13.1
Jedi environment: <SameEnvironment: 3.7.1 in /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7>
  • executable: /usr/local/bin/vim ERROR: failed to get sys path from environment: jedi.api.environment.InvalidPythonEnvironment: Could not get version information for ‘/usr/local/bin/vim’: UnpicklingError(“invalid load key, ‘3’.”) Traceback (most recent call last): File “/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi_vim_debug.py”, line 71, in display_debug_info sys_path = environment.get_sys_path() File “/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi/jedi/cache.py”, line 143, in wrapper result = method(self, *args, **kwargs) File “/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi/jedi/api/environment.py”, line 128, in get_sys_path return self._get_subprocess().get_sys_path() File “/Users/michael.hoyle/.vim/bundle/jedi-vim/pythonx/jedi/jedi/api/environment.py”, line 79, in _get_subprocess exc))
Settings
  omnifunc=jedi#completions
	Last set from ~/.vim/bundle/jedi-vim/autoload/jedi.vim line 612
  completeopt=menuone,longest,preview
	Last set from ~/.vim/bundle/jedi-vim/plugin/jedi.vim line 31

:version


VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 29 2018 06:57:16)
macOS version
Included patches: 1-500
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               ++builtin_terms    +cmdline_info      +diff              +farsi             -hangul_input      +libcall           +modify_fname      -mouse_sysmouse    +packages          +python3           +startuptime       +termguicolors     +user_commands     +wildignore        -xsmp
+arabic            +byte_offset       +comments          +digraphs          +file_in_path      +iconv             +linebreak         +mouse             +mouse_urxvt       +path_extra        +quickfix          +statusline        +terminal          +vartabs           +wildmenu          -xterm_clipboard
+autocmd           +channel           +conceal           -dnd               +find_in_path      +insert_expand     +lispindent        -mouseshape        +mouse_xterm       +perl              +reltime           -sun_workshop      +terminfo          +vertsplit         +windows           -xterm_save
+autochdir         +cindent           +cryptv            -ebcdic            +float             +job               +listcmds          +mouse_dec         +multi_byte        +persistent_undo   +rightleft         +syntax            +termresponse      +virtualedit       +writebackup       
-autoservername    -clientserver      +cscope            +emacs_tags        +folding           +jumplist          +localmap          -mouse_gpm         +multi_lang        +postscript        +ruby              +tag_binary        +textobjects       +visual            -X11               
-balloon_eval      +clipboard         +cursorbind        +eval              -footer            +keymap            -lua               -mouse_jsbterm     -mzscheme          +printer           +scrollbind        +tag_old_static    +timers            +visualextra       -xfontset          
+balloon_eval_term +cmdline_compl     +cursorshape       +ex_extra          +fork()            +lambda            +menu              +mouse_netterm     +netbeans_intg     +profile           +signs             -tag_any_white     +title             +viminfo           -xim               
-browse            +cmdline_hist      +dialog_con        +extra_search      -gettext           +langmap           +mksession         +mouse_sgr         +num64             -python            +smartindent       -tcl               -toolbar           +vreplace          -xpm               
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework AppKit   -mmacosx-version-min=10.12 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.28.0/lib/perl5/5.28.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -lruby.2.5.3 -lobjc    

:messages

Messages maintainer: Bram Moolenaar <Bram@vim.org>
"impact_service/impacts/models.py" 15L, 327C
:scriptnames
  1: ~/platform-impact-service/minimal.vimrc
  2: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim
  3: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim
  4: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/syntax/syntax.vim
  5: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/syntax/synload.vim
  6: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/syntax/syncolor.vim
  7: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/filetype.vim
  8: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/ftplugin.vim
  9: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/indent.vim
 10: ~/.vim/bundle/jedi-vim/plugin/jedi.vim
 11: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/getscriptPlugin.vim
 12: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/gzip.vim
 13: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/logiPat.vim
 14: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/manpager.vim
 15: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/matchparen.vim
 16: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/netrwPlugin.vim
 17: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/rrhelper.vim
 18: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/spellfile.vim
 19: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/tarPlugin.vim
 20: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/tohtml.vim
 21: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/vimballPlugin.vim
 22: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/plugin/zipPlugin.vim
 23: ~/unix-setup/vim/syntax/python.vim
 24: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/syntax/python.vim
 25: ~/.vim/bundle/jedi-vim/after/syntax/python.vim
 26: ~/.vim/bundle/jedi-vim/autoload/jedi.vim
 27: ~/.vim/bundle/jedi-vim/ftplugin/python/jedi.vim
 28: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/ftplugin/python.vim
 29: ~/unix-setup/vim/after/ftplugin/python.vim
 30: ~/.vim/bundle/jedi-vim/after/ftplugin/python/jedi.vim
 31: ~/unix-setup/vim/indent/python.vim
 32: /usr/local/Cellar/vim/8.1.0500/share/vim/vim81/indent/python.vim
```

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22

Most upvoted comments

a workaround is in your vimrc, change the executable :py3 sys.executable='/usr/local/bin/python3'

@bradwood What is :py3 import sys; print(sys.version_info) in Vim? It appears that your Vim only has Python 3. What does “inside a virtualenv” mean? Vim’s Python should be the same there, so what is different inside/outside a Virtualenv? (i.e. python -V)