davidhalter / jedi-vim

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

Error: jedi-vim failed to initialize Python: jedi-vim requires Vim with support for Python 3. (in function jedi#init_python[4]..<S NR>41_init_python, line 4) #1064

Closed ghost closed 3 years ago

ghost commented 3 years ago

Issue

I get the following error (see further below for the full output from JediDebugInfo!):

Error: jedi-vim failed to initialize Python: jedi-vim requires Vim with support for Python 3. (in function jedi#init_python[4]..<S
NR>41_init_python, line 4)

However, when I press enter at the prompt, it works as usual.

Note that I'm using Neovim.

Steps to reproduce

Only happens for me when I add the following. The problem disappears when this one line is removed (from init.vim):

" ... more stuff
language en_US
" ... more stuff

(My $LANG variable, if it helps: LANG=sv_SE.UTF-8.)

And then open a Python file to invoke jedi-vim.

Output of “:verbose JediDebugInfo”

Jedi-vim debug information

jedi-vim version
Global Python

Using Python version 3 to access Jedi. Error when trying to import vim: Vim(python3):E319: No "python3" provider found. Run ":checkhealth provider" python3 failed to run, likely a Python config issue. Try :checkhealth for more information.

Settings
  omnifunc=
  completeopt=menuone,longest,preview
    Last set from ~/.config/nvim/plugged/jedi-vim/plugin/jedi.vim line 36

:version


NVIM v0.5.0
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/build/config -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/src -I/usr/local/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/build/src/nvim/auto -I/tmp/neovim-20210702-14987-rep9di/neovim-0.5.0/build/include
Compiled by brew@BigSur

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.5.0/share/nvim"

Run :checkhealth for more info

:messages

Error detected while processing function jedi#init_python[11]..<SNR>41_display_exception:
line   19:
Error: jedi-vim failed to initialize Python: jedi-vim requires Vim with support for Python 3. (in function jedi#init_python[4]..<SNR>41_init_python, line 4)
Error: jedi-vim failed to initialize Python: jedi-vim requires Vim with support for Python 3. (in function jedi#init_python[4]..<SNR>41_init_python, line 4)
:scriptnames ``` 1: ~/.config/nvim/init.vim 2: ~/.config/nvim/autoload/plug.vim 3: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/filetype.vim 4: ~/.config/nvim/plugged/rust.vim/ftdetect/rust.vim 5: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/ftplugin.vim 6: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/indent.vim 7: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/syntax/syntax.vim 8: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/syntax/synload.vim 9: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/syntax/syncolor.vim 10: ~/.config/nvim/plugged/papercolor-theme/colors/PaperColor.vim 11: ~/.config/nvim/plugged/rust.vim/plugin/cargo.vim 12: ~/.config/nvim/plugged/rust.vim/plugin/rust.vim 13: ~/.config/nvim/plugged/jedi-vim/plugin/jedi.vim 14: ~/.config/nvim/plugged/vim-airline/plugin/airline.vim 15: ~/.config/nvim/plugged/vim-airline/autoload/airline/init.vim 16: ~/.config/nvim/plugged/vim-airline/autoload/airline/parts.vim 17: ~/.config/nvim/plugged/vim-airline/autoload/airline/formatter/short_path.vim 18: ~/.config/nvim/plugged/vim-airline/autoload/airline/util.vim 19: ~/.config/nvim/plugged/vim-airline-themes/plugin/airline-themes.vim 20: ~/.config/nvim/plugged/coc.nvim/plugin/coc.vim 21: ~/.config/nvim/plugged/coc.nvim/autoload/coc/rpc.vim 22: ~/.config/nvim/plugged/coc.nvim/autoload/coc/util.vim 23: ~/.config/nvim/plugged/coc.nvim/autoload/coc/client.vim 24: ~/.config/nvim/plugged/LanguageClient-neovim/plugin/LanguageClient.vim 25: ~/.config/nvim/plugged/fzf/plugin/fzf.vim 26: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/gzip.vim 27: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/health.vim 28: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/man.vim 29: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/matchit.vim 30: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim 31: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/matchparen.vim 32: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/netrwPlugin.vim 33: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/rplugin.vim 34: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/shada.vim 35: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/spellfile.vim 36: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/tarPlugin.vim 37: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/tohtml.vim 38: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/tutor.vim 39: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/zipPlugin.vim 40: ~/.config/nvim/plugged/jedi-vim/ftplugin/python/jedi.vim 41: ~/.config/nvim/plugged/jedi-vim/autoload/jedi.vim 42: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/autoload/provider/python3.vim 43: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/autoload/provider/pythonx.vim 44: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/autoload/remote/host.vim 45: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/ftplugin/python.vim 46: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/autoload/provider/python.vim 47: ~/.config/nvim/plugged/jedi-vim/after/ftplugin/python/jedi.vim 48: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/indent/python.vim 49: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/syntax/python.vim 50: ~/.config/nvim/plugged/jedi-vim/after/syntax/python.vim 51: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions.vim 52: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/quickfix.vim 53: ~/.config/nvim/plugged/vim-airline/autoload/airline.vim 54: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/netrw.vim 55: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/fzf.vim 56: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/term.vim 57: ~/.config/nvim/plugged/vim-airline/autoload/airline/section.vim 58: ~/.config/nvim/plugged/vim-airline/autoload/airline/highlighter.vim 59: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/hunks.vim 60: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/nvimlsp.vim 61: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/coc.vim 62: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/languageclient.vim 63: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/whitespace.vim 64: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/po.vim 65: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/wordcount.vim 66: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/keymap.vim 67: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/searchcount.vim 68: ~/.config/nvim/plugged/vim-airline-themes/autoload/airline/themes/papercolor.vim 69: ~/.config/nvim/plugged/vim-airline/autoload/airline/themes.vim 70: ~/.config/nvim/plugged/vim-airline/autoload/airline/builder.vim 71: ~/.config/nvim/plugged/vim-airline/autoload/airline/extensions/default.vim 72: ~/.config/nvim/plugged/LanguageClient-neovim/autoload/LanguageClient.vim 73: ~/.config/nvim/plugged/coc.nvim/autoload/coc/float.vim 74: ~/.config/nvim/plugged/coc.nvim/autoload/coc.vim 75: /private/var/folders/cy/2bjxrcwj4t18mr4wqljjqg5r0000gn/T/nvimb3I1Hr/coc.nvim-30996/coc-30996.vim 76: ~/.config/nvim/plugged/coc.nvim/autoload/coc/highlight.vim 77: /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/autoload/provider/clipboard.vim ```

:checkhealth provider gives me the following:

Checking /usr/local/bin/python3 caused an unknown error. (1, output: Fatal Python error:
config_get_locale_encoding: failed to get the locale encoding: nl_langinfo(CODESET) failed
Python runtime state: preinitialized
ghost commented 3 years ago

Found the issue. Use en_US.UTF-8 instead. 🤦 . Closing.

mazunki commented 2 years ago

I just arrived at this same error, but it wasn't related to language at all. Had to pip install pynvim. Also, nvim doesn't know 3.10 is newer than 3.9, so if you're using 3.10 you should make pip install it through python3.9 -m pip install ...

blueyed commented 2 years ago

@mazunki "jedi-vim requires Vim with support for Python 3" for Neovim implies that pynvim might be missing, yeah - maybe it could have a clearer error message in that case.

As for "nvim doesn't know 3.10 is newer than 3.9": this should not really matter, does it? Or is it due to nvim picking 3.9 over 3.10? IIRC it should prefer the first one with pynvim / that works, but is certainly more an issue for/with nvim.

mazunki commented 2 years ago

Re: @blueyed

I have Python 3.9 and Python 3.10 installed on my computer. python3 symlinked to python3.10. Thus pip install --user pynvim installs pynvim for Python 3.10. Since python3 (that is, 3.10) is inferior to Python 3.3 or whatever it demands as a minimum, it goes to the next option: Python 3.9. Seeing as pip hasn't installed pynvim for Python 3.9, but only Python 3.10, it claims I don't have it anywhere.

If Neovim knew Python 3.10 was a valid Python version, it would work to just pip-install it as normally, without having to call the module from within the specific subversion. Python 3.10 is still not fully released, though.

In regards to the error message, yeah. It would be nice for it to hint at :checkhealth provider, although I quickly found that through a search.