Debugging Python when using Poetry and Pyenv#
This guide is based on this guide on reddit
Then, in emacs-land, install with-venv and add the following snippet wherever you tend to add snippets:
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: January 23, 2023