jorgenschaefer / elpy

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

Flymake immediately crashing on all new Python files opened #1859

Open awood45 opened 3 years ago

awood45 commented 3 years ago

Summary

Whenever I open a new Python file, I get the following error:

Flymake: Configuration error has occurred while running (black /PATH/TO/MY/PROJECT/setup_flymake.py). Flymake will be switched OFF > OK

The black part doesn't seem to matter, if I disable '(elpy-syntax-check-command "black") all other syntax checkers will fail with the exact same message.

The *Messages* buffer also shows the following messages preceding this failure:

Making python-shell-interpreter local to  *Python Internal [d78b2acce95628d9b2610290347a0f95]* while let-bound!
Making python-shell-interpreter-args local to  *Python Internal [d78b2acce95628d9b2610290347a0f95]* while let-bound!

Steps to reproduce

In my case, any time I open up a Python file. I have another laptop where this doesn't seem to happen, including on the same projects, but I haven't quite been able to divine the material difference yet.

My configuration

OS

OSX

Result of (elpy-config)

   1 │ Elpy Configuration
   2 │
   3 │ Emacs.............: 24.5.1
   4 │ Elpy..............: 1.35.0
   5 │ Virtualenv........: None
   6 │ Interactive Python: ipython 7.12.0 (/Users/alexwood/.pyenv/shims/ipython)
   7 │ RPC virtualenv....: rpc-venv (/Users/alexwood/.emacs.d/elpy/rpc-venv)
   8 │  Python...........: python 3.7.5 (/Users/alexwood/.emacs.d/elpy/rpc-venv/bin/python)
   9 │  Jedi.............: Not found (0.17.2 available)
  10 │  Rope.............: Not found (0.18.0 available)
  11 │  Autopep8.........: Not found (1.5.4 available)
  12 │  Yapf.............: Not found (0.30.0 available)
  13 │  Black............: Not found (20.8b1 available)
  14 │ Syntax checker....: black (/Users/alexwood/.pyenv/shims/black)
  15 │
  16 │ Warnings
  17 │
  18 │ You have not activated a virtual env. It is not mandatory but often a
  19 │ good idea to work inside a virtual env. You can use `M-x
  20 │ pyvenv-activate` or `M-x pyvenv-workon` to activate one.
  21 │
  22 │ The directory ~/.local/bin/ is not in your PATH. As there is no active
  23 │ virtualenv, installing Python packages locally will place executables
  24 │ in that directory, so Emacs won't find them. If you are missing some
  25 │ commands, do add this directory to your PATH -- and then do
  26 │ `elpy-rpc-restart'.
  27 │
  28 │ The Jedi package is not currently installed. This package is needed
  29 │ for code completion, code navigation and access to documentation.
  30 │
  31 │ [Install jedi]
  32 │
  33 │ No autoformatting package is currently installed. At least one is
  34 │ needed (Autopep8, Yapf or Black) to perform autoformatting (`C-c C-r
  35 │ f` in a python buffer).
  36 │
  37 │ [Install autopep8]
  38 │ [Install yapf]
  39 │ [Install black]
  40 │
  41 │ Options
  42 │
  43 │ Square brackets indicate buttons; type RET or click mouse-1 on a
  44 │ button to invoke its action.  Invoke [+] to expand a group, and [-] to
  45 │ collapse an expanded group.  Invoke the [Group], [Face], and [Option]
  46 │ buttons below to edit that item in another window.
  47 │
  48 │ [+]-- [Group] Elpy
  49 │ [+]-- [Group] Python
  50 │ [+]-- [Group] Virtual Environments (Pyvenv)
  51 │ [+]-- [Group] Completion (Company)
  52 │ [+]-- [Group] Call Signatures (ElDoc)
  53 │ [+]-- [Group] Inline Errors (Flymake)
  54 │ [+]-- [Group] Code folding (hideshow)
  55 │ [+]-- [Group] Snippets (YASnippet)
  56 │ [+]-- [Group] Directory Grep (rgrep)
  57 │ [+]-- [Group] Search as You Type (ido)
  58 │ [+]-- [Group] Django extension
  59 │ [+]-- [Group] Autodoc extension

(I will note that turning on a virtualenv does nothing for this error.)

Elpy configuration in my init.el

I have a whole file structure, but here are the relevant parts - happy to dive in deeper if there may be something else relevant.

 121 │ ;; Python Support
 122 │ (add-to-list 'load-path "~/emacs-tools/python")
 123 │ (require 'blacken)
 124 │
 125 │ (install-package-if-missing 'flycheck) ;; install-package-if-missing is a method of my own design, works fine
 126 │ (install-package-if-missing 'elpy)
 127 │ (require 'elpy)
 128 │ (elpy-enable)
 129 │ (add-hook 'python-mode-hook 'blacken-mode)
 130 │ (setq python-shell-interpreter "ipython"
 131 │       python-shell-interpreter-args "-i --simple-prompt")

(custom-set-variables '(elpy-syntax-check-command "black"))

  21 │ (setq python-shell-prompt-detect-failure-warning nil)
  22 │
  23 │ (setq elpy-default-minor-modes '(eldoc-mode
  24 │                                  highlight-indentation-mode
  25 │                                  yas-minor-mode
  26 │                                  auto-complete-mode))
whompyjaw commented 3 years ago

I apologize if I am stating the obvious, but I think you need to make sure your config is setup. You don't have anything installed in your elpy-config. Maybe Flymake depends on these? This should get prompted when you create/open a python file. Not sure why it's not...

But I'm still Elpy/Emacs noob and your config file makes me think you know what you're doing. So sorry if my comment isn't all that helpful. :/

awood45 commented 3 years ago

It's not outside the realm of possibility that I've misconfigured something, though I don't think that's the cause here:

whompyjaw commented 3 years ago

Sorry, I should have elaborated on what I meant by "prompted". IIRC, when I saved a python file (or when I called M-x elpy-config), the RPC process began installing all the necessary sub packages (as listed in elpy-config), and everything gets installed. Sadly, I can't remember if this happened when I saved a python file or when I called elpy-config

This is my elpy-config result.


Elpy..............: 1.35.0
Virtualenv........: env (c:/Users/user/Documents/env/)
Interactive Python: python 3.8.2 (c:/Users/user/Scripts/python.exe)
RPC virtualenv....: rpc-venv (c:/Users/user/.emacs.d/elpy/rpc-venv)
 Python...........: c:/WINDOWS/py.exe 3.9.0 (c:/WINDOWS/py.exe)
 Jedi.............: 0.17.2
 Rope.............: 0.18.0
 Autopep8.........: 1.5.4
 Yapf.............: 0.30.0
 Black............: 20.8b1
Syntax checker....: flake8.exe (c:/Users/user/AppData/Local/Programs/Python/Python39/Scripts/flake8.exe)```