Closed msMatix closed 7 months ago
I have the same problem
If I use the config from here, it can debug normally, it should be a bug in nvim-dap-python
https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#python
my config
return {
{
"jay-babu/mason-nvim-dap.nvim",
config = function(_, opts)
require("mason-nvim-dap").setup(opts)
local dap = require("dap")
dap.adapters.python = function(cb, config)
if config.request == "attach" then
---@diagnostic disable-next-line: undefined-field
local port = (config.connect or config).port
---@diagnostic disable-next-line: undefined-field
local host = (config.connect or config).host or "127.0.0.1"
cb({
type = "server",
port = assert(port, "`connect.port` is required for a python `attach` configuration"),
host = host,
options = {
source_filetype = "python",
},
})
else
cb({
type = "executable",
command = "C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\pythonw.exe",
args = { "-m", "debugpy.adapter" },
options = {
source_filetype = "python",
},
})
end
end
dap.configurations.python = {
{
-- The first three options are required by nvim-dap
type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python`
request = "launch",
name = "Launch file",
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
program = "${file}", -- This configuration will launch the current file if used.
pythonPath = function()
-- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
-- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
-- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
local cwd = vim.fn.getcwd()
if vim.fn.executable(cwd .. "/venv/Scripts/pythonw.exe") == 1 then
return cwd .. "/venv/Scripts/pythonw.exe"
elseif vim.fn.executable(cwd .. "/.venv/Scripts/pythonw.exe") == 1 then
return cwd .. "/.venv/Scripts/pythonw.exe"
else
return "C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\pythonw.exe"
end
end,
},
}
end,
},
}
If I use the config from here, it can debug normally, it should be a bug in nvim-dap-python
https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#python
my config
return { { "jay-babu/mason-nvim-dap.nvim", config = function(_, opts) require("mason-nvim-dap").setup(opts) local dap = require("dap") dap.adapters.python = function(cb, config) if config.request == "attach" then ---@diagnostic disable-next-line: undefined-field local port = (config.connect or config).port ---@diagnostic disable-next-line: undefined-field local host = (config.connect or config).host or "127.0.0.1" cb({ type = "server", port = assert(port, "`connect.port` is required for a python `attach` configuration"), host = host, options = { source_filetype = "python", }, }) else cb({ type = "executable", command = "C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\pythonw.exe", args = { "-m", "debugpy.adapter" }, options = { source_filetype = "python", }, }) end end dap.configurations.python = { { -- The first three options are required by nvim-dap type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python` request = "launch", name = "Launch file", -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options program = "${file}", -- This configuration will launch the current file if used. pythonPath = function() -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable. local cwd = vim.fn.getcwd() if vim.fn.executable(cwd .. "/venv/Scripts/pythonw.exe") == 1 then return cwd .. "/venv/Scripts/pythonw.exe" elseif vim.fn.executable(cwd .. "/.venv/Scripts/pythonw.exe") == 1 then return cwd .. "/.venv/Scripts/pythonw.exe" else return "C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python311\\pythonw.exe" end end, }, } end, }, }
Using this config, and changing the paths to reflect my local machine resulted in being able to debug normally, without any external shell window from opening up. Thank YOU
Just ran into this issue as well. @akthe-at 's response helped point me in the right direction, but ultimately is not very portable. I managed to solve it with https://github.com/linux-cultist/venv-selector.nvim , just make sure to enable the dap_enabled
option (and to activate a venv before debugging your code)
Hello, I wanted to debug my application on windows with nvim-dap-python. However, I get the following warning message: The debug adapter did not respond. Either the adapter is slow (then wait and ignore) or there is a problem with your adapter in the 'python' configuration.
Furthermore I get with the cmd DapShowLog the following hint:
However, my configuration works fine on my Linux system. I have now seen in some hints that there are issues with windows.
My configuration is as follows:
Additionally, I use LazyVim framework. My guess is at the path. However, when I print the path in the setup method, I get the correct path. Can someone help me here? If you need more information, please contact me.
Thanks in advance.