Debugging Python when using Poetry and Pyenv#
This guide is based on this guide on reddit
One seemingly sane stack for Python development is Poetry + Pyenv. To debug a project using poetry, start by running
poetry config virtualenvs.in-project true
poetry add --group dev debugpy
poetry install
(use-package dap-mode
:after lsp-mode
:commands dap-debug
:hook ((python-mode . dap-ui-mode) (python-mode . dap-mode))
:config
(require 'dap-python)
(setq dap-python-debugger 'debugpy)
(defun dap-python--pyenv-executable-find (command)
(with-venv (executable-find "python")))
(add-hook 'dap-stopped-hook
(lambda (arg) (call-interactively #'dap-hydra))))
You should now be able to debug your projects by calling dap-hydra
as normal.
Last update:
November 1, 2024