jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 262 forks source link

peculiar error: "exited abnormally with code 1" - apparently an encoding issue #1729

Closed Krisselack closed 3 years ago

Krisselack commented 4 years ago

Summary

I keep getting this error continuously: error in process sentinel: elpy-rpc--default-error-callback: peculiar error: "exited abnormally with code 1" error in process sentinel: peculiar error: "exited abnormally with code 1"

Then the panel freezes for 1 sec or so, making elpy quite unusable on a win10 machine.

Steps to reproduce

open a .py file

My configuration

OS

Win10

Result of (elpy-config)

Elpy Configuration

Emacs.............: 26.1
Elpy..............: 1.32.0
Virtualenv........: None
Interactive Python: python 3.7.3 (c:/Users/.../AppData/Local/Programs/Python/Python37/python.exe)
RPC virtualenv....: rpc-venv (c:/Users/.../.emacs.d/elpy/rpc-venv)
 Python...........: C:/Users/.../AppData/Local/Programs/Python/Python37/python.exe 3.7.3 (C:/Users/.../AppData/Local/Programs/Python/Python37/python.exe)
 Jedi.............: 0.15.1
 Rope.............: 0.14.0
 Autopep8.........: 1.4.4
 Yapf.............: 0.28.0
 Black............: 19.10b0
Syntax checker....: flake8.exe (c:/Users/.../AppData/Local/Programs/Python/Python37/Scripts/flake8.exe)

Warnings

You have not activated a virtual env. While Elpy supports this, it is
often a good idea to work inside a virtual env. You can use M-x
pyvenv-activate or M-x pyvenv-workon to activate a virtual env.

Pip doesn't seem to be installed in the dedicated virtualenv created
by Elpy (c:/Users/brandstaetterc/.emacs.d/elpy/rpc-venv). This will
prevent some features from working properly (completion,
documentation, reformatting, ...). You can try reinstalling the
virtualenv with `elpy-rpc-reinstall-virtualenv'. If the problem
persists, please report on Elpy's github page.

Options

`Raised' text indicates buttons; type RET or click mouse-1 on a button
to invoke its action.  Invoke [+] to expand a group, and [-] to
collapse an expanded group.  Invoke the [Group], [Face], and [Option]
buttons below to edit that item in another window.

Elpy configuration in my init.el

(require 'elpy)
(elpy-enable)
 (eval-after-load "elpy"
   '(define-key elpy-mode-map (kbd "<C-return>") 'elpy-shell-send-region-or-buffer))
(setq elpy-rpc-python-command "C:/Users/../AppData/Local/Programs/Python/Python37/python.exe")

output: (elpy-rpc-init (elpy-library-root))

Debugger entered--Lisp error: (wrong-number-of-arguments (2 . 4) 1)
  elpy-rpc-init("../test.py")
  eval((elpy-rpc-init (elpy-library-root)) nil)
  eval-expression((elpy-rpc-init (elpy-library-root)) nil nil 127)
  funcall-interactively(eval-expression (elpy-rpc-init (elpy-library-root)) nil nil 127)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)
Krisselack commented 4 years ago

The issue disappeared after setting: (set-language-environment "UTF-8") in my init. Windows uses a different encoding. Maybe this can be included?

galaunay commented 4 years ago

There is some issues in windows I am trying to fix. Thanks for the report and the info about encoding, very helpful.

I will fix this (if possible) or add a note in the documentation for windows users.

Krisselack commented 4 years ago

I managed to solve it with adding the following to my .emacs:

(setenv "PYTHONIOENCODING" "utf-8") (add-to-list 'process-coding-system-alist '("elpy" . (utf-8 . utf-8))) (add-to-list 'process-coding-system-alist '("python" . (utf-8 . utf-8))) (add-to-list 'process-coding-system-alist '("flake8" . (utf-8 . utf-8)))

Alternatively, (set-language-environment "UTF-8") this worked, but screwed up my R-setup.

thornjad commented 3 years ago

I'm suddenly getting this same error continuously from Ubuntu 21.04, despite using elpy successfully for years. @Krisselack's solution didn't seem to make any difference. Every time this errors, it freezes up Emacs for a second or so, so I've had to disable elpy. Here's the backtrace I'm getting (scrubbed of some file names). This error came from a remote file, but it also happens locally:

Debugger entered--Lisp error: (process-sentinel "exited abnormally with code 1")
  elpy-rpc--default-error-callback((process-sentinel "exited abnormally with code 1"))
  elpy-promise-reject([*elpy-promise* #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_30> elpy-rpc--default-error-callback #<buffer  *elpy-rpc [project:/ssh:*****:/*********/test/fixtures/ environment:/usr]*> nil] (process-sentinel "exited abnormally with code 1"))
  #f(compiled-function (call-id promise) #<bytecode 0x112dd5626b194b59>)(1 [*elpy-promise* #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_30> elpy-rpc--default-error-callback #<buffer  *elpy-rpc [project:/ssh:*****:/**********/test/fixtures/ environment:/usr]*> nil])
  elpy-rpc--sentinel(#<process  *elpy-rpc [project:/ssh:*****:/*********/test/fixtures/ environment:/usr]*> "exited abnormally with code 1\n")

Instead, what solved it for me was completely removing elpy from Emacs (in my case, deleting it from the straight.el cache), and re-installing. Suddenly, no problems.

Krisselack commented 3 years ago

In the meantime I also stopped using elpy in windows. Thd problem kind of returned after updating.

brtsay commented 3 years ago

Similar to @thornjad, completely uninstalling and reinstalling fixed this issue for me (which cropped up after I updated elpy). Completely uninstalling in my case also involved deleting the elpy folder in .emacs.d. After reinstalling, it will ask

Automatically install the RPC dependencies from PyPI (needed for completion, autoformatting and documentation) ? y
Elpy is installing the RPC dependencies...
Done

Seems to work fine now after this.

t3pleni9 commented 3 years ago

I was only facing this issue whenever elpy was running outside virtual envs, and all of my virtual envs have python3. I was able to fix the issue by updating the elpy-rpc-python-command variable to point to python3 instead of the default python, which in most system for backward compatibility is set to python 2.7. On the restart elpy did what @brtsay has mentioned in the output.

Krisselack commented 3 years ago

Thanks to your recent activity @brtsay and @t3pleni9, I gave it another go.

I also completely removed my elpy (incl. elpy-folder in .emacs.d) and reinstalled the melpa version. Looks good so far: sphinx, flymake/flake, jedi, ...

Last time I tried, emacs started to become incredibly slow and unusable... this seems to have been fixed. I will close the issue for now. Also many thanks to @jorgenschaefer

r-ithikinwisconsin commented 3 years ago

Hi all. I am using MELPA and I am encountering this issue...I can't even run M-x elpy-config, it says it can't find python excecutable, despite me adding it to PATH. Any help?

jeffofx commented 3 years ago

I'm having this problem. I've tried everything in this thread, and others. The two error messages are these:

error in process sentinel: elpy-rpc--default-error-callback: peculiar error: "exited abnormally with code 1" error in process sentinel: peculiar error: "exited abnormally with code 1"

MacOS 11.5.2 Big Sur Emacs 27.2 pipenv 2021.5.29

It happens with Python 3.9.7 while inside pipenv, and also with MacOS's legacy Python 2.7.16 when outside pipenv.

EMACS INSTALLED PACKAGES:

better-defaults-20210222.1928
company-20210909.1505
elpy-20210630.2317
highlight-indentation-20210221.1418 material-theme-20210904.1226
pyvenv-20210527.829
s-20210616.619
yasnippet-20200604.246

Elpy Configuration:

Emacs.............: 27.2 Elpy..............: 1.35.0 Virtualenv........: None Interactive Python: python 3.9.7 (/Users/[]/.local/share/virtualenvs/scrap-1fa-HuZ1/bin/python) RPC virtualenv....: rpc-venv (/Users/[]/.emacs.d/elpy/rpc-venv) Python...........: python3 3.8.2 (/Users/[]/.emacs.d/elpy/rpc-venv/bin/python3) Jedi.............: Not found (0.18.0 available) Autopep8.........: Not found (1.5.7 available) Yapf.............: Not found (0.31.0 available) Black............: Not found (21.9b0 available) Syntax checker....: Not found (flake8)

jeffofx commented 3 years ago

Ok, I made one change, installing Jedi, and that fixed it. Seems to be working fine in both pipenv/Python3 and straight Python2.7.16.

So now:

Elpy Configuration:

Emacs.............: 27.2 Elpy..............: 1.35.0 Virtualenv........: None Interactive Python: python 3.9.7 (/Users/[]/.local/share/virtualenvs/scrap-1fa-HuZ1/bin/python) RPC virtualenv....: rpc-venv (/Users/[]/.emacs.d/elpy/rpc-venv) Python...........: python3 3.8.2 (/Users/[]/.emacs.d/elpy/rpc-venv/bin/python3) Jedi.............: 0.18.0 Autopep8.........: Not found (1.5.7 available) Yapf.............: Not found (0.31.0 available) Black............: Not found (21.9b0 available) Syntax checker....: Not found (flake8)

flora-sun-zhixin commented 3 years ago

I am using mac Catalina 10.15.7, emacs 27.2, elpy 1.35.0, I use a virtual environment basing on python3.7. Then encountered "exit abnormally with code 1" and freezed for about 1s every time. In my previous config, jedi, autopep8, yapf and black are not find. Then I figure it might be because that the rpc cannot be properly initialized. After running M-x elpy-rpc-reinstall-virtualenv it fixed the issue also set up the jedi and other packages for me. Hope this helps.