Reputation: 1239
I am using emacs as python IDE. I am having flymake installed, however, it shows the following error whenever I work with a .py file
Error (flymake): Flymake: Failed to launch syntax check process 'pycheckers' with args (string-operations_flymake.py): Searching for program: no such file or directory, pycheckers. Flymake will be switched OFF
My .emacs configuration for flymake is as follows:
;; flymake
(add-to-list 'load-path "~/.emacs.d/vendor")
(add-hook 'find-file-hook 'flymake-find-file-hook)
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pycheckers" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
(load "~/.emacs.d/vendor/flymake-cursor.el")
(global-set-key [f10] 'flymake-goto-prev-error)
(global-set-key [f11] 'flymake-goto-next-error)
Any suggestions on how to resolve this
Upvotes: 7
Views: 4331
Reputation: 295
I will explain how to use flymake in GNU Emacs 29.4.
Let's assume that we want to use flymake on this Python file (see code block below) that uses syntax compliant to Python 3.10. Note that the last print
statement has a syntax erorr: it is missing the closing parentheses.
print('foo')
print('bar')
print('baz'
We need to install a syntax checker for Python 3.10. I will install flake8
, all available syntax checkers supported for Python by flymake is in python-flymake-command
.
python3.10 -m pip install flake8
Upon execution of the command, you can get the location where it was installed using pip show
, in the field Location
.
pip show flake8
Name: flake8
Version: 7.1.1
Summary: the modular source code checker: pep8 pyflakes and co
Home-page: https://github.com/pycqa/flake8
Author: Tarek Ziade
Author-email: [email protected]
License: MIT
Location: /home/rodrigo/.local/lib/python3.10/site-packages
Requires: mccabe, pycodestyle, pyflakes
Required-by:
In my system, the binary flake8
was located in /home/rodrigo/.local/bin/flake8
.
We need to tell Emacs where the binary flake8
is located, we have two options: (1) we could add /home/rodrigo/.local/bin/
to $PATH
in the shell where Emacs will be started or (2) we could add /home/rodrigo/.local/bin/
to the Emacs variable exec-path
. I'll use (1).
We can start Emacs by running the command shown below. Note: I have used emacs -Q
, so that none of my configurations are loaded just to show how vanilla Emacs behaves. Note: we don't need to load a configuration file because in GNU Emacs 29.4, flymake is a built-in package.
PATH="/home/rodrigo/.local/bin:$PATH" emacs -Q /tmp/a.py
If we execute flymake-mode
, the last line should be underlined. If we move the point to the underlined line, the syntax error is shown in the minibuffer (see screenshot below).
If we execute flymake-show-buffer-diagnostics
, the buffer *Flyamke diagnostics for `a.py`*
will be shown (see screenshot below).
Upvotes: 0