davidhalter / jedi-vim

Using the jedi autocompletion library for VIM.
MIT License
5.27k stars 370 forks source link

Jedi-vim yield the error on startup: ImportError: bad magic number in 'jedi.common': b'\x03\xf3\r\n' #1024

Closed petRUShka closed 4 years ago

petRUShka commented 4 years ago

Issue

After update to commit https://github.com/davidhalter/jedi-vim/commit/a17b0333031bd3652ad4c6169caaed05ffb7c49d (Update Jedi to v0.17.2) Jedi won't start on python files with an error:

ERROR: could not import the "jedi" Python module: ImportError: bad magic number in 'jedi.common': b'\x03\xf3\r\n'

If I come back to https://github.com/davidhalter/jedi-vim/commit/a0207fadf9f165adac61f01abc07db0ae898cbe6 everything is working as usual.

Steps to reproduce

  1. Setup vimrc_minimal_jedi:
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
let g:jedi#completions_enabled = 0

syntax on
filetype plugin indent on
  1. cd ~/vim/plugged/jedi-vim and execute vim test.py -u vimrc_minimal_jedi.
  2. Get the error.

Output of “:verbose JediDebugInfo”

More details from :JediDebugInfo:

Jedi-vim debug information

jedi-vim version
Global Python

Using Python version 3 to access Jedi.

Settings
g:jedi#completions_enabled = 0 (default: 1)

  omnifunc=python3complete#Complete
        Last set from /usr/share/vim/vim82/ftplugin/python.vim line 41
  completeopt=menuone,longest,preview
        Last set from ~/vim/.vim/plugged/jedi-vim/plugin/jedi.vim line 36

:version

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jun 21 2020 16:11:23)
Included patches: 1-814
Compiled by Arch Linux
Huge version without GUI.  Features included (+) or not (-):
+acl               +cmdline_info      -farsi             +langmap           +mouse_sgr         +profile           +tag_binary        +virtualedit
+arabic            +comments          +file_in_path      +libcall           -mouse_sysmouse    +python/dyn        -tag_old_static    +visual
+autocmd           +conceal           +find_in_path      +linebreak         +mouse_urxvt       +python3/dyn       -tag_any_white     +visualextra
+autochdir         +cryptv            +float             +lispindent        +mouse_xterm       +quickfix          +tcl/dyn           +viminfo
-autoservername    +cscope            +folding           +listcmds          +multi_byte        +reltime           +termguicolors     +vreplace
-balloon_eval      +cursorbind        -footer            +localmap          +multi_lang        +rightleft         +terminal          +wildignore
+balloon_eval_term +cursorshape       +fork()            +lua/dyn           -mzscheme          +ruby/dyn          +terminfo          +wildmenu
-browse            +dialog_con        +gettext           +menu              +netbeans_intg     +scrollbind        +termresponse      +windows
++builtin_terms    +diff              -hangul_input      +mksession         +num64             +signs             +textobjects       +writebackup
+byte_offset       +digraphs          +iconv             +modify_fname      +packages          +smartindent       +textprop          -X11
+channel           -dnd               +insert_expand     +mouse             +path_extra        -sound             +timers            -xfontset
+cindent           -ebcdic            +ipv6              -mouseshape        +perl/dyn          +spell             +title             -xim
-clientserver      +emacs_tags        +job               +mouse_dec         +persistent_undo   +startuptime       -toolbar           -xpm
-clipboard         +eval              +jumplist          +mouse_gpm         +popupwin          +statusline        +user_commands     -xsmp
+cmdline_compl     +ex_extra          +keymap            -mouse_jsbterm     +postscript        -sun_workshop      +vartabs           -xterm_clipboard
+cmdline_hist      +extra_search      +lambda            +mouse_netterm     +printer           +syntax            +vertsplit         -xterm_save
   system vimrc file: "/etc/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/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.
32/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim        -lm -ltinfo -lelf    -lacl -lattr -lgpm -ld
l   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.32/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib  -L/usr/li
b/perl5/5.32/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm

:messages

jedi-vim error: jedi#setup_python_imports: ImportError: bad magic number in 'jedi.common': b'\x03\xf3\r\n'
  Traceback (most recent call last):
    File "/home/user/vim/.vim/plugged/jedi-vim/pythonx/jedi_vim.py", line 114, in <module>
      import jedi
    File "/home/user/vim/.vim/plugged/jedi-vim/pythonx/jedi/jedi/__init__.py", line 32, in <module>
      from jedi.api import Script, Interpreter, set_debug_function, \
    File "/home/user/vim/.vim/plugged/jedi-vim/pythonx/jedi/jedi/api/__init__.py", line 24, in <module>
      from jedi.api import Script, Interpreter, set_debug_function, \
    File "/home/user/vim/.vim/plugged/jedi-vim/pythonx/jedi/jedi/api/__init__.py", line 24, in <module>
      from jedi.api import classes
    File "/home/user/vim/.vim/plugged/jedi-vim/pythonx/jedi/jedi/api/classes.py", line 24, in <module>
      from jedi.inference.utils import unite
    File "/home/user/vim/.vim/plugged/jedi-vim/pythonx/jedi/jedi/inference/__init__.py", line 70, in <module>
      from jedi.inference import imports
    File "/home/user/vim/.vim/plugged/jedi-vim/pythonx/jedi/jedi/inference/imports.py", line 24, in <module>
      from jedi.common import traverse_parents
Error detected while processing function jedi#init_python[11]..<SNR>26_display_exception:
line   19:
Error: jedi-vim failed to initialize Python: jedi#setup_python_imports: ImportError: bad magic number in 'jedi.common': b'\x03\xf3\r\n' (in function jedi#init_
python[4]..<SNR>26_init_python[27]..jedi#setup_python_imports, line 32). See :messages and/or :JediDebugInfo for more information.
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jun 21 2020 16:11:23)
:scriptnames ``` 1: ~/vim/.vim/plugged/jedi-vim/vimrc_minimal_jedi 2: /usr/share/vim/vim82/syntax/syntax.vim 3: /usr/share/vim/vim82/syntax/synload.vim 4: /usr/share/vim/vim82/syntax/syncolor.vim 5: /usr/share/vim/vim82/filetype.vim 6: /usr/share/vim/vimfiles/ftdetect/augeas.vim 7: /usr/share/vim/vimfiles/ftdetect/icinga2.vim 8: /usr/share/vim/vimfiles/ftdetect/vagrantfile.vim 9: /usr/share/vim/vim82/ftplugin.vim 10: /usr/share/vim/vim82/indent.vim 11: /usr/share/vim/vim82/plugin/getscriptPlugin.vim 12: /usr/share/vim/vim82/plugin/gzip.vim 13: /usr/share/vim/vim82/plugin/logiPat.vim 14: /usr/share/vim/vim82/plugin/manpager.vim 15: /usr/share/vim/vim82/plugin/matchparen.vim 16: /usr/share/vim/vim82/plugin/netrwPlugin.vim 17: /usr/share/vim/vim82/plugin/rrhelper.vim 18: /usr/share/vim/vim82/plugin/spellfile.vim 19: /usr/share/vim/vim82/plugin/tarPlugin.vim 20: /usr/share/vim/vim82/plugin/tohtml.vim 21: /usr/share/vim/vim82/plugin/vimballPlugin.vim 22: /usr/share/vim/vim82/plugin/zipPlugin.vim 23: ~/vim/.vim/plugged/jedi-vim/plugin/jedi.vim 24: /usr/share/vim/vim82/syntax/python.vim 25: ~/vim/.vim/plugged/jedi-vim/after/syntax/python.vim 26: ~/vim/.vim/plugged/jedi-vim/autoload/jedi.vim 27: /usr/share/vim/vim82/ftplugin/python.vim 28: ~/vim/.vim/plugged/jedi-vim/ftplugin/python/jedi.vim 29: ~/vim/.vim/plugged/jedi-vim/after/ftplugin/python/jedi.vim 30: /usr/share/vim/vim82/indent/python.vim 31: /usr/share/vim/vim82/syntax/vim.vim 32: /usr/share/vim/vim82/syntax/lua.vim 33: /usr/share/vim/vim82/syntax/perl.vim 34: /usr/share/vim/vim82/syntax/pod.vim 35: /usr/share/vim/vim82/syntax/ruby.vim 36: /usr/share/vim/vim82/ftplugin/vim.vim 37: /usr/share/vim/vim82/indent/vim.vim ```
davidhalter commented 4 years ago

This means that your Jedi installation is broken. Remove the folder and reinstall it.

(You can also just clear all pyc files in the Jedi folder)