Python In Emacs

5 minute read

Add this to your doom.d/init.el file (replace the existing python line with this):

`(python +lsp)            ; beautiful is better than ugly`

Install Python Language Server Protocal (LSP)

$ pip install ‘python-lsp-server[all]’

Run doom sync

$ doom sync

Create Python file:

<spc> <spc> foo.py

Add some code:

def hi():
  print("helllo")
hi()

Save Python file:

<spc> f s

Start python language server:

M-x run-python or spc-: run-python

In `foo.py`, send code over to language server for the server to run:

C-c C-c

Bonus: Doom Doctor

Run doom doctor and install all the python dependencies to get all the integrations to work