尝试使用 dap 模式在 emacs 中调试 Python 文件时,dap-server-path 为零?

问题描述 投票:0回答:1

我尝试运行

dap-python
来调试 Python 文件,但出现以下错误:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  dap--create-session((:type "python" :cwd "/home/yelnat/Documents/programmin/python-test/" :request "launch" :name "My App" :program "/home/yelnat/Documents/programmin/python-test/test..." :args [] :dap-server-path (nil "-m" "debugpy.adapter")))
  dap-start-debugging-noexpand((:type "python" :cwd "/home/yelnat/Documents/programmin/python-test/" :request "launch" :name "My App" :program "/home/yelnat/Documents/programmin/python-test/test..." :args [] :dap-server-path (nil "-m" "debugpy.adapter")))
  #f(compiled-function () #<bytecode -0x785353ff795e90b>)()
  dap-debug((:type "python" :args "" :cwd "/home/yelnat/Documents/programmin/python-test/" :request "launch" :name "My App"))
  funcall-interactively(dap-debug (:type "python" :args "" :cwd "/home/yelnat/Documents/programmin/python-test/" :request "launch" :name "My App"))
  command-execute(dap-debug record)
  execute-extended-command(nil "dap-debug" "dap-deb")
  funcall-interactively(execute-extended-command nil "dap-debug" "dap-deb")
  command-execute(execute-extended-command)

我尝试了一些不同的配置文件,并在 dap 网站上搜索了答案,但我找不到它说明 dap 服务器应该在哪里。

我认为唯一可能导致该问题的原因是我使用 Debian 12 并安装了 Python 3.10 版本来安装我可能需要的任何系统范围的软件包(如

debugpy
之类的软件包)。我为Python3.10设置了别名并使用
exec-path-from-shell
,但我不确定这是否会影响
dap-mode
,所以它可能使用我的没有debugpy的python版本。

emacs dot-emacs
1个回答
0
投票

我有一个解决方案,但它相当快速且肮脏。我刚刚设置了从 /bin/python 到 /bin/python3 的链接(通过执行

sudo ln -s /bin/python3  /bin/python
),这允许 dap 找到 python 解释器。如果有人知道如何将 python 解释器的路径传递给 dap,那可能是最好的解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.