pythonic-emacs / anaconda-mode

Code navigation, documentation lookup and completion for Python.
GNU General Public License v3.0
707 stars 87 forks source link

Server error: RuntimeError('generator raised StopIteration') #343

Closed some-mthfka closed 4 years ago

some-mthfka commented 5 years ago

Hi! The error in the title appears when when trying to autocomplete.

I did both pip install setuptools and pacman -Sy setuptools.

I have updated Anaconda-mode to the latest version.

Python version: 3.7.1

Looks like it's a bug and has to do with the latest python version: https://stackoverflow.com/questions/51700960/runtimeerror-generator-raised-stopiteration-every-time-i-try-to-run-app

anaconda_mode port 46213
127.0.0.1 - - [11/Dec/2018 00:59:08] ================================================================================
Traceback (most recent call last):
  File "/home/meat/.emacs.d/anaconda-mode/0.1.13/jedi-0.13.1-py3.7.egg/jedi/api/completion.py", line 43, in filter_names
    k = (new.name, new.complete)  # key
  File "/home/meat/.emacs.d/anaconda-mode/0.1.13/jedi-0.13.1-py3.7.egg/jedi/api/classes.py", line 434, in complete
    return self._complete(True)
  File "/home/meat/.emacs.d/anaconda-mode/0.1.13/jedi-0.13.1-py3.7.egg/jedi/api/classes.py", line 403, in _complete
    if self._name.api_type == 'param' and self._stack is not None:
  File "/home/meat/.emacs.d/anaconda-mode/0.1.13/jedi-0.13.1-py3.7.egg/jedi/evaluate/compiled/context.py", line 237, in api_type
    return next(iter(self.infer())).api_type
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/meat/.emacs.d/anaconda-mode/0.1.13/service_factory-0.1.5-py3.7.egg/service_factory/service.py", line 101, in apply
    result = method(**params)
  File "<string>", line 95, in wrapper
  File "<string>", line 116, in complete
  File "/home/meat/.emacs.d/anaconda-mode/0.1.13/jedi-0.13.1-py3.7.egg/jedi/api/__init__.py", line 179, in completions
    completions = completion.completions()
  File "/home/meat/.emacs.d/anaconda-mode/0.1.13/jedi-0.13.1-py3.7.egg/jedi/api/completion.py", line 103, in completions
    return sorted(completions, key=lambda x: (x.name.startswith('__'),
RuntimeError: generator raised StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/meat/.emacs.d/anaconda-mode/0.1.13/service_factory-0.1.5-py3.7.egg/service_factory/providers/basehttp.py", line 40, in do_POST
    status, response = self.server.service(data)
  File "/home/meat/.emacs.d/anaconda-mode/0.1.13/service_factory-0.1.5-py3.7.egg/service_factory/service.py", line 50, in __call__
    result = self.apply(method, args)
  File "/home/meat/.emacs.d/anaconda-mode/0.1.13/service_factory-0.1.5-py3.7.egg/service_factory/service.py", line 105, in apply
    server_error(args['id'], error)
  File "/home/meat/.emacs.d/anaconda-mode/0.1.13/service_factory-0.1.5-py3.7.egg/service_factory/errors.py", line 91, in server_error
    raise ServiceException(500, dumps(response))
service_factory.exceptions.ServiceException: (500, '{"jsonrpc": "2.0", "id": 1, "error": {"code": -32000, "message": "Server error", "data": "RuntimeError(\'generator raised StopIteration\')"}}')
valignatev commented 5 years ago

Yeah, Jedi isn't fully ready for Python 3.7 yet: https://github.com/davidhalter/jedi/blob/master/.travis.yml#L22-L25

valignatev commented 5 years ago

One way you could mitigate an issue is by installing Python 3.6 with something like pyenv and making anaconda-mode use it by pointing emacs' python-shell-interpreter to it. Something like (setq python-shell-interpreter "/path/to/python3.6") or by (customize-set-variable 'python-shell-interpreter "/path/to/python3.6")

The same applies to virtual environment, of course

some-mthfka commented 5 years ago

@valignatev OK, I will give it a try one of these days. Thank you!

CeleritasCelery commented 4 years ago

Python 3.7 is currently supported in Jedi. Closing this issue unless the issue persists.