Python IDE interactions in emacs without a language server
I really enjoy my minimal Emacs
configuration with pyvenv
,
eglot
and pyright
language server when developing
Python programs. The usual workflow for me is:
- activate
pyvenv
environmentM-x pyvenv-activate
M-x pyvenv-mode
(if I want the virtual env to be shown in the mode line, the previous command enables the venv anyway)
- or use
poetry-venv-activate
if the project uses poetry for package management and emacs has poetry.el installed. Alternatively, one can usepyvenv
and point it to the poetry env on the system M-x eglot
and pickpyright-languageserver
(it should be installed in the environment)
Nevertheless, there are times that I don't want the language server to be active or if I don't want to install it in a remote server to which I am connected over SSH and tramp. For this cases I use the following workflow to be able to find definitions or references of an object and run linting:
M-x project-compile
find . -name '*.py' | etags -
to populate tags using GNU etags- use
M-x xref-find-definitions
(or its keybinding which isg d
in Emacs evil) orM-x xref-find-references
and use the TAGS file created in the root of the project - for linting and errors I do
M-x project-compile
followed bypyright .
1 orpylint *
and useprevious-error
andnext-error
keybinds to jump between errors
This provides almost everything I would need for simple and lightweight Python development environment.

pylint *
and focus on click or using next-error
Footnotes:
for pyright errors to show correctly in the emacs compilation mode, the following needs to be added the Emacs configurations:
↩︎push 'pyright compilation-error-regexp-alist) (push '(pyright "^\\ +\\(.+\\):\\([0-9]+\\):\\([0-9]+\\).+$" 1 2 3) compilation-error-regexp-alist-alist) (