Skip to content

PYTHONPATH in dap-debug #202

Closed
Closed
@lccambiaghi

Description

@lccambiaghi

How can I set the env variable PYTHONPATH when I run dap-debug?

My debug template looks like:

    (dap-register-debug-template "Debug Python"
                             (list :type "python"
                                   :args "-i"
                                   :cwd (expand-file-name "~/git/projectname")
                                   :env '(("PYTHONPATH" . "/Users/luca/git/projectname/src/"))
                                   :request "launch"
                                   :name "Python :: Run Configuration"))

And I get an error in the first lines because of a failed import.

I use direnv-mode and in my .envrc file I have exported my PYTHONPATH. It seems the env variable is not picked up by dap-mode. This works for pytest, the env variables are set like this: https://github.com/wbolster/emacs-python-pytest/blob/master/python-pytest.el#L529-L531 . I tried to replicate the same behaviour with:

(after! (direnv dap-python)
  (defvar direnv-non-file-modes)
  (add-to-list 'direnv-non-file-modes 'dap-mode))

but it does not work.

Thank you for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions