davidhalter / jedi-vim

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

jedi-vim fails to start with `ModuleNotFoundError: No module named jedi-vim` #1079

Open cesarosum opened 2 years ago

cesarosum commented 2 years ago

Issue

Unable to launch jedi-vim. Error is:

Error detected while processing BufRead Autocommands for "*.py"..FileType Autocommands for "*"..function <SNR>4_LoadFTPlugin[17]..script /c/Users/F720969/.vim/pack/plugins/start/jedi-vim/ftplugin/python/jedi.vim[1]../c/Users/F720969/.vim/pack/plugins/start/jedi-vim/autoload/jedi.vim[260]..function jedi#init_python[13]..BufRead Autocommands for "*.py"..FileType Autocommands for "*"..function <SNR>4_LoadFTPlugin[17]..script /c/Users/F720969/.vim/pack/plugins/start/jedi-vim/ftplugin/python/jedi.vim[1]../c/Users/F720969/.vim/pack/plugins/start/jedi-vim/autoload/jedi.vim[260]..function jedi#init_python[11]..<SNR>25_display_exception:
line   19:
Error: jedi-vim failed to initialize Python: jedi#setup_python_imports: Traceback (most recent call last): (in BufRead Autocommands for "*.py"..FileType Autocommands for "*"..function <SNR>4_LoadFTPlugin[17]..script /c/Users/F720969/.vim/pack/plugins/start/jedi-vim/ftplugin/python/jedi.vim[1]../c/Users/F720969/.vim/pack/plugins/start/jedi-vim/autoload/jedi.vim[260]..function jedi#init_python[4]..<SNR>25_init_python[6]..jedi#setup_python_imports, line 20). See :messages and/or :JediDebugInfo for more information.
Error detected while processing BufRead Autocommands for "*.py"..FileType Autocommands for "*"..function <SNR>4_LoadFTPlugin[17]..script /c/Users/F720969/.vim/pack/plugins/start/jedi-vim/ftplugin/python/jedi.vim:
line   36:
E117: Unknown function: jedi#configure_call_signatures

After typing :messages, I get

jedi-vim error: jedi#setup_python_imports: Traceback (most recent call last):
  File "<string>", line 10, in <module>
ModuleNotFoundError: No module named 'jedi_vim'

Steps to reproduce

Running Vim 8.2 on Windows 10 with +python3/dyn. Installed Python is 3.9.

Can confirm that echo has('python3') returns 1.

Running :python3 import sys; print(sys.version)' returns3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]`.

Can confirm this matches the output of running python --version.

Installed jedi-vim into .vim/pack/plugins/start via git clone --recursive. Subsequently ran git submodule update --init --recursive.

The minimal.vimrc I used:

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

set pythonthreehome=C:\<path-to>\python3.9\\latest
set pythonthreedll=C:\<path-to>\python39.dll

syntax on
filetype plugin indent on

Opening a .py file then produces the error.

Output of “:verbose JediDebugInfo”

#### Jedi-vim debug information

##### jedi-vim version

 - jedi-vim git version: 0.11.0-29-g32d05f7
 - jedi git submodule status:  fae26fa7a427b94a21e11500503d8008647e6309 pythonx/jedi (v0.18.1)
 - parso git submodule status:  ee5edaf22ff3941cbdfa4efd8cb3e8f69779fd56 pythonx/parso (v0.8.3)

##### Global Python

Using Python version 3 to access Jedi.
Error when running display_debug_info: Vim(python3):ModuleNotFoundError: No module named 'jedi_vim_debug'

##### Settings

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

#### :version

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 21 2021 16:13:20)
Included patches: 1-3441
Compiled by <https://www.msys2.org/>
Huge version without GUI.  Features included (+) or not (-):
+acl               -clientserver      +diff              +folding           +langmap           +mouse_dec         +num64             +reltime           +syntax            +title             +windows
+arabic            +clipboard         +digraphs          -footer            +libcall           -mouse_gpm         +packages          +rightleft         +tag_binary        -toolbar           +writebackup
+autocmd           +cmdline_compl     -dnd               +fork()            +linebreak         -mouse_jsbterm     +path_extra        +ruby/dyn          -tag_old_static    +user_commands     -X11
+autochdir         +cmdline_hist      -ebcdic            +gettext           +lispindent        +mouse_netterm     +perl/dyn          +scrollbind        -tag_any_white     +vartabs           -xfontset
-autoservername    +cmdline_info      +emacs_tags        -hangul_input      +listcmds          +mouse_sgr         +persistent_undo   +signs             -tcl               +vertsplit         -xim
-balloon_eval      +comments          +eval              +iconv             +localmap          -mouse_sysmouse    +popupwin          +smartindent       +termguicolors     +virtualedit       -xpm
+balloon_eval_term +conceal           +ex_extra          +insert_expand     -lua               +mouse_urxvt       +postscript        -sodium            +terminal          +visual            -xsmp
-browse            +cryptv            +extra_search      +ipv6              +menu              +mouse_xterm       +printer           -sound             +terminfo          +visualextra       -xterm_clipboard
++builtin_terms    +cscope            -farsi             +job               +mksession         +multi_byte        +profile           +spell             +termresponse      +viminfo           -xterm_save
+byte_offset       +cursorbind        +file_in_path      +jumplist          +modify_fname      +multi_lang        -python            +startuptime       +textobjects       +vreplace
+channel           +cursorshape       +find_in_path      +keymap            +mouse             -mzscheme          +python3/dyn       +statusline        +textprop          +wildignore
+cindent           +dialog_con        +float             +lambda            -mouseshape        +netbeans_intg     +quickfix          -sun_workshop      +timers            +wildmenu
   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: "/etc"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim82"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/include/ncursesw -march=x86-64 -mtune=generic -O2 -pipe -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -pipe -fstack-protector-strong -pipe -Wl,--as-needed -o vim.exe -lm -lncursesw -liconv -lacl -lintl -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -ldl -lcrypt

#### :messages

"my-first-script.py" 0L, 0B
jedi-vim error: jedi#setup_python_imports: Traceback (most recent call last):
  File "<string>", line 10, in <module>
ModuleNotFoundError: No module named 'jedi_vim'
Error detected while processing BufRead Autocommands for "*.py"..FileType Autocommands for "*"..Syntax Autocommands for "*"..function <SNR>3_SynSet[25]..script /c/Users/F720969/.vim/pack/plugins/start/jedi-vim/after/syntax/python.vim[1]../c/Users/F720969/.vim/pack/plugins/start/jedi-vim/autoload/jedi.vim[260]..function jedi#init_python[13]..BufRead Autocommands for "*.py"..FileType Autocommands for "*"..Syntax Autocommands for "*"..function <SNR>3_SynSet[25]..script /c/Users/F720969/.vim/pack/plugins/start/jedi-vim/after/syntax/python.vim[1]../c/Users/F720969/.vim/pack/plugins/start/jedi-vim/autoload/jedi.vim[260]..function jedi#init_python[11]..<SNR>24_display_exception:
line   19:
Error: jedi-vim failed to initialize Python: jedi#setup_python_imports: Traceback (most recent call last): (in BufRead Autocommands for "*.py"..FileType Autocommands for "*"..Syntax Autocommands for "*"..function <SNR>3_SynSet[25]..script /c/Users/F720969/.vim/pack/plugins/start/jedi-vim/after/syntax/python.vim[1]../c/Users/F720969/.vim/pack/plugins/start/jedi-vim/autoload/jedi.vim[260]..function jedi#init_python[4]..<SNR>24_init_python[6]..jedi#setup_python_imports, line 20). See :messages and/or :JediDebugInfo for more information.
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 21 2021 16:13:20)

<details><summary>:scriptnames</summary>

  1: ~/Codebase/python-test/minimal.vimrc
  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/vim82/syntax/python.vim
  7: /usr/share/vim/vim82/ftplugin.vim
  8: /usr/share/vim/vim82/indent.vim
  9: /usr/share/vim/vim82/plugin/getscriptPlugin.vim
 10: /usr/share/vim/vim82/plugin/gzip.vim
 11: /usr/share/vim/vim82/plugin/logiPat.vim
 12: /usr/share/vim/vim82/plugin/manpager.vim
 13: /usr/share/vim/vim82/plugin/matchparen.vim
 14: /usr/share/vim/vim82/plugin/netrwPlugin.vim
 15: /usr/share/vim/vim82/plugin/rrhelper.vim
 16: /usr/share/vim/vim82/plugin/spellfile.vim
 17: /usr/share/vim/vim82/plugin/tarPlugin.vim
 18: /usr/share/vim/vim82/plugin/tohtml.vim
 19: /usr/share/vim/vim82/plugin/vimballPlugin.vim
 20: /usr/share/vim/vim82/plugin/zipPlugin.vim
 21: ~/.vim/pack/plugins/start/jedi-vim/plugin/jedi.vim
 22: ~/.vim/pack/plugins/start/lightline.vim/plugin/lightline.vim
 23: ~/.vim/pack/plugins/start/jedi-vim/after/syntax/python.vim
 24: ~/.vim/pack/plugins/start/jedi-vim/autoload/jedi.vim
 25: ~/.vim/pack/plugins/start/jedi-vim/ftplugin/python/jedi.vim
 26: /usr/share/vim/vim82/ftplugin/python.vim
 27: ~/.vim/pack/plugins/start/jedi-vim/after/ftplugin/python/jedi.vim
 28: /usr/share/vim/vim82/indent/python.vim
 29: ~/.vim/pack/plugins/start/lightline.vim/autoload/lightline.vim
 30: ~/.vim/pack/plugins/start/lightline.vim/autoload/lightline/tab.vim
 31: ~/.vim/pack/plugins/start/lightline.vim/autoload/lightline/colorscheme/default.vim
 32: ~/.vim/pack/plugins/start/lightline.vim/autoload/lightline/colorscheme/powerline.vim
 33: ~/.vim/pack/plugins/start/lightline.vim/autoload/lightline/colorscheme.vim

</details>
davidhalter commented 2 years ago

I have no idea what's wrong here.

Since jedi_vim_debug is not found, I feel like there's something wrong with your VIM installation. It's definitely a new issue that I haven't seen before.

cesarosum commented 2 years ago

OK I will try reinstalling VIM as a first step and report back if the issue persists.

cesarosum commented 2 years ago

I tried reinstalling VIM but the error persists.

I have also tried installation using Vundle but again no luck.

davidhalter commented 2 years ago

It's strange, because you seem to be the only person that has this issue.

cesarosum commented 2 years ago

Yeah it's a doozy :-)

For what it's worth, I created a .pth file in Lib\site-packages containing the path to jedi-vim\pythonx under the assumption that the problem was that python simply didn't know where to look. Got the following errors now -

.vimrc" [unix] 45L, 786B
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<path-to>\.vim\bundle\jedi-vim\pythonx\jedi_vim.py", line 116, in <module>
    import jedi
  File "<path-to>\.vim\bundle\jedi-vim\pythonx\jedi\jedi\__init__.py", line 32, in <module>
    from jedi.api import Script, Interpreter, set_debug_function, preload_module
  File "<path-to>\.vim\bundle\jedi-vim\pythonx\jedi\jedi\api\__init__.py", line 13, in <module>
    import parso
  File "<path-to>\.vim\bundle\jedi-vim\pythonx\parso\parso\__init__.py", line 42, in <module>
    from parso.grammar import Grammar, load_grammar
  File "<path-to>\.vim\bundle\jedi-vim\pythonx\parso\parso\grammar.py", line 13, in <module>
    from parso.cache import parser_cache, load_module, try_to_save_module
  File "<path-to>\.vim\bundle\jedi-vim\pythonx\parso\parso\cache.py", line 76, in <module>
    _default_cache_path = _get_default_cache_path()
  File "<path-to>\.vim\bundle\jedi-vim\pythonx\parso\parso\cache.py", line 73, in _get_default_cache_path
    return dir_.expanduser()
  File "<path-to>\python3.9\latest\lib\pathlib.py", line 1572, in expanduser
    homedir = self._flavour.gethomedir(self._parts[0][1:])
  File "<path-to>\python3.9\latest\lib\pathlib.py", line 276, in gethomedir
    raise RuntimeError("Can't determine home directory")
RuntimeError: Can't determine home directory
"Codebase/python-test/my-first-script.py" [unix] 1L, 9B
jedi-vim error: jedi#setup_python_imports: Traceback (most recent call last):

  File "<string>", line 10, in <module>

  File "<path-to>\.vim\bundle\jedi-vim\pythonx\jedi_vim.py", line 116, in <module>
    import jedi

  File "<path-to>\.vim\bundle\jedi-vim\pythonx\jedi\jedi\__init__.py", line 32, in <module>
    from jedi.api import Script, Interpreter, set_debug_function, preload_module

  File "<path-to>\.vim\bundle\jedi-vim\pythonx\jedi\jedi\api\__init__.py", line 13, in <module>
    import parso

  File "<path-to>\.vim\bundle\jedi-vim\pythonx\parso\parso\__init__.py", line 42, in <module>
    from parso.grammar import Grammar, load_grammar

  File "<path-to>\.vim\bundle\jedi-vim\pythonx\parso\parso\grammar.py", line 13, in <module>
    from parso.cache import parser_cache, load_module, try_to_save_module

  File "<path-to>\.vim\bundle\jedi-vim\pythonx\parso\parso\cache.py", line 76, in <module>
    _default_cache_path = _get_default_cache_path()

  File "<path-to>\.vim\bundle\jedi-vim\pythonx\parso\parso\cache.py", line 73, in _get_default_cache_path
    return dir_.expanduser()

  File "<path-to>\python3.9\latest\lib\pathlib.py", line 1572, in expanduser
    homedir = self._flavour.gethomedir(self._parts[0][1:])

  File "<path-to>\python3.9\latest\lib\pathlib.py", line 276, in gethomedir
    raise RuntimeError("Can't determine home directory")

RuntimeError: Can't determine home directory
Error detected while processing BufRead Autocommands for "*.py"..FileType Autocommands for "*"..function <SNR>4_LoadFTPlugin[17]..script  <path-to>/.vim/bundle/jedi-vim/ftplugin/python/jedi.vim[1]..<path-to>/.vim/bundle/jedi-vim/autoload/jedi.vim[260]..function               jedi#init_python[13]..BufRead Autocommands for "*.py"..FileType Autocommands for "*"..function <SNR>4_LoadFTPlugin[17]..script <path-to>/.vim/bundle/jedi-vim/ftplugin/python/jedi.vim[1]..<path-to>/.vim/bundle/jedi-vim/autoload/jedi.vim[260]..function jedi#init_python[11]..   <SNR>54_display_exception:
line   19:
Error: jedi-vim failed to initialize Python: jedi#setup_python_imports: Traceback (most recent call last): (in BufRead Autocommands for   "*.py"..FileType Autocommands for "*"..function <SNR>4_LoadFTPlugin[17]..script <path-to>/.vim/bundle/jedi-vim/ftplugin/python/jedi.      vim[1]..<path-to>/.vim/bundle/jedi-vim/autoload/jedi.vim[260]..function jedi#init_python[4]..<SNR>54_init_python[6]..                     jedi#setup_python_imports, line 20). See :messages and/or :JediDebugInfo for more information.
Error detected while processing BufRead Autocommands for "*.py"..FileType Autocommands for "*"..function <SNR>4_LoadFTPlugin[17]..script  <path-to>/.vim/bundle/jedi-vim/ftplugin/python/jedi.vim:
line   36:
E117: Unknown function: jedi#configure_call_signatures
cesarosum commented 2 years ago

And indeed, the output of :python3 import os; for key in os.environ.keys(); print(key) yields

ANSICON
ANSICON_DEF
CONEMUANSI
PATH
SYSTEMDRIVE
SYSTEMROOT
WINDIR

HOME is noticeably absent.

davidhalter commented 2 years ago

This looks like something's broken with either Python3 or VIM, but I have a very limited knowledge about that interaction. Maybe reinstalling Python3.9 from a different source?

AminMasoudi commented 8 months ago

well i have the same issue :) on debian


Error detected while processing BufNewFile Autocommands for "*.py"..FileType Autocommands for "*"..function <SNR>9_LoadFTPlugin[18]..script /home/amin/.vim/bundle/jedi-vim/ftplugin/python/jedi.vim[1]../home/amin
/.vim/bundle/jedi-vim/autoload/jedi.vim[261]..function jedi#init_python[13]..BufNewFile Autocommands for "*.py"..FileType Autocommands for "*"..function <SNR>9_LoadFTPlugin[18]..script /home/amin/.vim/bundle/jed
i-vim/ftplugin/python/jedi.vim[1]../home/amin/.vim/bundle/jedi-vim/autoload/jedi.vim[261]..function jedi#init_python[11]..<SNR>27_display_exception:
line   19:
Error: jedi-vim failed to initialize Python: jedi-vim requires Vim with support for Python 3. (in BufNewFile Autocommands for "*.py"..FileType Autocommands for "*"..function <SNR>9_LoadFTPlugin[18]..script /home
/amin/.vim/bundle/jedi-vim/ftplugin/python/jedi.vim[1]../home/amin/.vim/bundle/jedi-vim/autoload/jedi.vim[261]..function jedi#init_python[4]..<SNR>27_init_python, line 4)
Error detected while processing BufNewFile Autocommands for "*.py"..FileType Autocommands for "*"..function <SNR>9_LoadFTPlugin[18]..script /home/amin/.vim/bundle/jedi-vim/ftplugin/python/jedi.vim:
line   40:
E117: Unknown function: jedi#configure_call_signatures
felipealfonsog commented 8 months ago

Just fixed it adding this plugin:
Plugin 'davidhalter/jedi-vim'