davidhalter / jedi-vim

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

edi.api.environment.InvalidPythonEnvironment: Could not get version information for '/usr/bin/python': InternalError("The subprocess /usr/bin/python has crashed (EOFError('Ran out of input'), stderr=).") #1075

Closed bgenchel closed 2 years ago

bgenchel commented 2 years ago

Issue

Using Jedi through YCM, latest version. Using a Macbook pro on Monterey 12.1 Seems something is wrong with my system default python, and I haven't been able to find any issues that match this particular one exactly either in this issue tracker or on stack overflow so I thought i'd post it here.

I install YCM via vim plug, then compile it with python3. The version of jedi in its dependencies doesn't appear to be the most recent, but has grammars up to 310.

When I open vim with a python file, I immediately see the error in the issue title in my command bar at the bottom of the screen. Opening the YCM logs yields this stack trace:

Traceback (most recent call last):
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/compiled/subprocess/__init__.py", line 248, in _send
    is_exception, traceback, result = pickle_load(self._get_process().stdout)
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/jedi_deps/jedi/jedi/_compatibility.py", line 28, in pickle_load
    return pickle.load(file)
EOFError: Ran out of input

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/jedi_deps/jedi/jedi/api/environment.py", line 77, in _get_subprocess
    info = self._subprocess._send(None, _get_info)
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/compiled/subprocess/__init__.py", line 256, in _send
    raise InternalError(
jedi.api.exceptions.InternalError: The subprocess /usr/bin/python has crashed (EOFError('Ran out of input'), stderr=).

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 868, in _handle
    return route.call(**args)
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 1748, in wrapper
    rv = callback(*a, **ka)
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/watchdog_plugin.py", line 97, in wrapper
    return callback( *args, **kwargs )
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/hmac_plugin.py", line 62, in wrapper
    body = callback( *args, **kwargs )
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/handlers.py", line 91, in RunCompleterCommand
    return _JsonResponse( completer.OnUserCommand(
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/completers/completer.py", line 473, in OnUserCommand
    return command( self, request_data, arguments[ 1: ] )
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/completers/python/python_completer.py", line 293, in <lambda>
    self._GetDoc( request_data ) ),
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/completers/python/python_completer.py", line 443, in _GetDoc
    definitions = self._GetJediScript( request_data ).goto( line, column )
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/completers/python/python_completer.py", line 169, in _GetJediScript
    environment = self._EnvironmentForRequest( request_data )
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/completers/python/python_completer.py", line 122, in _EnvironmentForRequest
    environment = self._EnvironmentForInterpreterPath( interpreter_path )
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/completers/python/python_completer.py", line 107, in _EnvironmentForInterpreterPath
    jedi.create_environment( interpreter_path, safe = False ) )
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/jedi_deps/jedi/jedi/api/environment.py", line 366, in create_environment
    return Environment(path, env_vars=env_vars)
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/jedi_deps/jedi/jedi/api/environment.py", line 68, in __init__
    self._get_subprocess()
  File "/Users/genche/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/jedi_deps/jedi/jedi/api/environment.py", line 79, in _get_subprocess
    raise InvalidPythonEnvironment(
jedi.api.environment.InvalidPythonEnvironment: Could not get version information for '/usr/bin/python': InternalError("The subprocess /usr/bin/python has crashed (EOFError('Ran out of input'), stderr=).")

Steps to reproduce

Install Vim (MacVim): VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 01 2021 08:32:44) macOS version - x86_64

Install YCM via vim plug as in:

 call plug#begin('~/.vim/plugged')
 ...
 Plug 'Valloric/YouCompleteMe'
 Plug 'rdnetto/YCM-Generator', {'branch': 'stable'}
 ...
 call plug#end()

in vim, use :PlugInstall to install. cd ~/.vim/plugged/YouCompleteMe and run python3 install.py --clang-completer --ts-completer

Open vim again with any python file and look at the debug logs (via :YcmToggleDebugLogs)

You can use the following template (save it as minimal.vimrc in the directory where jedi-vim is installed, cd into that directory, and run Vim with vim -u minimal.vimrc):

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

Please provide the minimal.vimrc you have used here, too. -->

Output of “:verbose JediDebugInfo”

I'm not sure how to execute the command for getting the debug information requested. I don't know what a Python buffer is in the context of VIm, or how to execute the command in one. Please provide further instructions.

davidhalter commented 2 years ago

Since this plugin is not part of YCM, you should probably report this on the YCM tracker. I'm closing, because this is the wrong repository. jedi-vim is an alternative to YCM.

To me it looks like your /usr/bin/python is either Python2 or there are some issues with it in general. We have had users having issues with macOS system Python previously. Most users I guess just install Python with brew/MacPorts or whatever else there is (I have never been a Mac user).