mfussenegger / nvim-dap-python

An extension for nvim-dap, providing default configurations for python and methods to debug individual test methods or classes.
GNU General Public License v3.0
492 stars 46 forks source link

ModuleImportError when running from Pyenv #119

Closed ca-mantis-shrimp closed 8 months ago

ca-mantis-shrimp commented 9 months ago

Hello!

Appreciate all your hard work on this plugin.

Im trying to get this working with pyenv and I keep getting a Module Import Error when trying to debug a file from my pyenv virtual environment

Im currently using the LazyVim Extra for Python with the following small snippet to try and customize this for use with pyenv:

{ "mfussenegger/nvim-dap-python", config = function() require("dap-python").setup(vim.g.python_host_prog) require('dap-python').test_runner = 'pytest' require('dap-python').resolve_python = function() return vim.g.python_host_prog end end, }, just incase, here is my option line where i set the python_host_prog option: vim.g.python_host_prog = vim.fn.expand('$HOME/.pyenv/versions/3.12.0/envs/dev3.12.0/bin/python') vim.g.python3_host_prog = vim.fn.expand('$HOME/.pyenv/versions/3.12.0/envs/dev3.12.0/bin/python')

I think I am experiencing something similar to #69, however, i dont currently use any kind of config file for the pyenv settings, im trying to follow neovim best-practices and just have a single development environment from which to work.

As you can see, I try utilizing the function you defined in the issue, as well as setting the initial setting on startup but i still get the module error as shown in this test: image

Thank you again for your time and expertise, please let me know if there is any more information i can provide

mfussenegger commented 9 months ago

Are VIRTUAL_ENV or CONDA_PREFIX environment variables set? The resolve_python function is only used as fallback.

Can you check the logs for the launch request payload? (log level set to trace via :DapSetLogLevel TRACE, then start a session and check :DapShowLog)

ca-mantis-shrimp commented 9 months ago

Thank you for your quick response,

Yes, this is where things get strange, and I didn't know if it would be worth the extra space but ill include it now. Ive been looking at the :checkhealth provider command and here is the output: "$VIRTUAL_ENV is set to: /home/darburgess/.pyenv/versions/3.12.0/envs/dev3.12.0" "But $PATH yields this python executable: /home/darburgess/.pyenv/versions/dev3.12.0/bin/python"

Here is the output of the launch request payload from a minimal python file for testing

{
  command = "launch",
  request_seq = 1,
  seq = 9,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] {
  body = {
    isLocalProcess = true,
    name = "/home/darburgess/test_http/test_debug.py",
    pointerSize = 64,
    startMethod = "launch",
    systemProcessId = 4310
  },
  event = "process",
  seq = 10,
  type = "event"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] {
  body = {
    reason = "started",
    threadId = 1
  },
  event = "thread",
  seq = 11,
  type = "event"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    allThreadsStopped = true,
    description = "No module named 'pandas'",
    preserveFocusHint = false,
    reason = "exception",
    text = "ModuleNotFoundError",
    threadId = 1
  },
  event = "stopped",
  seq = 12,
  type = "event"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1677 ]    "request"   {
  command = "threads",
  seq = 6,
  type = "request"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    threads = { {
        id = 1,
        name = "MainThread"
      } }
  },
  command = "threads",
  request_seq = 6,
  seq = 13,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1677 ]    "request"   {
  arguments = {
    threadId = 1
  },
  command = "stackTrace",
  seq = 7,
  type = "request"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    stackFrames = { {
        column = 1,
        endColumn = 14,
        id = 2,
        line = 1,
        name = "<module>",
        source = {
          path = "/home/darburgess/test_http/test_debug.py",
          sourceReference = 0
        }
      } },
    totalFrames = 1
  },
  command = "stackTrace",
  request_seq = 7,
  seq = 14,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1677 ]    "request"   {
  arguments = {
    threadId = 1
  },
  command = "exceptionInfo",
  seq = 8,
  type = "request"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    module = {
      id = 0,
      name = "__main__",
      path = "/home/darburgess/test_http/test_debug.py"
    },
    reason = "new"
  },
  event = "module",
  seq = 15,
  type = "event"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    module = {
      id = 1,
      name = "runpy",
      path = "/home/darburgess/.pyenv/versions/3.12.0/lib/python3.12/runpy.py"
    },
    reason = "new"
  },
  event = "module",
  seq = 16,
  type = "event"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    breakMode = "unhandled",
    description = "No module named 'pandas'",
    details = {
      message = "No module named 'pandas'",
      source = "/home/darburgess/test_http/test_debug.py",
      stackTrace = "  File \"/home/darburgess/test_http/test_debug.py\", line 1, in <module>\n    import pandas\nModuleNotFoundError: No module named 'pandas'\n",
      typeName = "ModuleNotFoundError"
    },
    exceptionId = "ModuleNotFoundError"
  },
  command = "exceptionInfo",
  request_seq = 8,
  seq = 17,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1677 ]    "request"   {
  arguments = {
    frameId = 2
  },
  command = "scopes",
  seq = 9,
  type = "request"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    scopes = { {
        expensive = false,
        name = "Locals",
        presentationHint = "locals",
        source = vim.empty_dict(),
        variablesReference = 3
      }, {
        expensive = false,
        name = "Globals",
        source = vim.empty_dict(),
        variablesReference = 4
      } }
  },
  command = "scopes",
  request_seq = 9,
  seq = 18,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1677 ]    "request"   {
  arguments = {
    variablesReference = 3
  },
  command = "variables",
  seq = 10,
  type = "request"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1677 ]    "request"   {
  arguments = {
    variablesReference = 4
  },
  command = "variables",
  seq = 11,
  type = "request"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1677 ]    "request"   {
  arguments = {
    variablesReference = 3
  },
  command = "variables",
  seq = 12,
  type = "request"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1677 ]    "request"   {
  arguments = {
    threadId = 1
  },
  command = "stackTrace",
  seq = 13,
  type = "request"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    variables = { {
        evaluateName = "special variables",
        name = "special variables",
        type = "",
        value = "",
        variablesReference = 5
      } }
  },
  command = "variables",
  request_seq = 10,
  seq = 19,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    variables = { {
        evaluateName = "special variables",
        name = "special variables",
        type = "",
        value = "",
        variablesReference = 6
      } }
  },
  command = "variables",
  request_seq = 11,
  seq = 20,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    variables = { {
        evaluateName = "special variables",
        name = "special variables",
        type = "",
        value = "",
        variablesReference = 7
      } }
  },
  command = "variables",
  request_seq = 12,
  seq = 21,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1677 ]    "request"   {
  arguments = {
    variablesReference = 4
  },
  command = "variables",
  seq = 14,
  type = "request"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    stackFrames = { {
        column = 1,
        endColumn = 14,
        id = 2,
        line = 1,
        name = "<module>",
        source = {
          path = "/home/darburgess/test_http/test_debug.py",
          sourceReference = 0
        }
      } },
    totalFrames = 1
  },
  command = "stackTrace",
  request_seq = 13,
  seq = 22,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1677 ]    "request"   {
  arguments = {
    threadId = 1
  },
  command = "stackTrace",
  seq = 15,
  type = "request"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    variables = { {
        evaluateName = "special variables",
        name = "special variables",
        type = "",
        value = "",
        variablesReference = 8
      } }
  },
  command = "variables",
  request_seq = 14,
  seq = 23,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-10-14T09:53:12Z-0700 ] ...gess/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 1   {
  body = {
    stackFrames = { {
        column = 1,
        endColumn = 14,
        id = 2,
        line = 1,
        name = "<module>",
        source = {
          path = "/home/darburgess/test_http/test_debug.py",
          sourceReference = 0
        }
      } },
    totalFrames = 1
  },
  command = "stackTrace",
  request_seq = 15,
  seq = 24,
  success = true,
  type = "response"
}

Apologies if i included way too much log, Im not adept at reading them and dont know how much is relevant, I can update for clarity if there is a specific part to focus on but i can see this catches the exception I was covering

mfussenegger commented 9 months ago

The log cut off the request, it starts with the response which doesn't include the information I wanted to see. There should be a pythonPath property somewhere.

And in any case I'd avoid putting all dependencies into the same python installation, but instead use one virtulaenv per project. Otherwise you're going to run into package conflicts sooner or later.

ca-mantis-shrimp commented 8 months ago

Thanks for your reply,

Ill send the chunk later when I can restart debugger.

As far as the virtual environment piece goes, this is an issue I have been trying to deal with for awhile. I completely agree that one should do per-project virtual environments, but the structure of the python provider in neovim encourages developers to use a single environment for development since you have to set the python path up-front, and mason assumes that the dependencies persist between startups.

Is the answer that one needs to set the python_host_prog upon startup based on the virtual environment? Because I was primarily doing this to get the damn thing working before I started handling the prospect of dynamic virtual environment management

mfussenegger commented 8 months ago

but the structure of the python provider in neovim encourages developers to use a single environment for development

This is not the case. :help python-virtualenv actually recommends the opposite - to use 1 dedicated virtualenv with pynvim installed for python3_host_prog.

E.g. you could have:

Alternatively you can install debugpy also in the pynvim environment, given that it has no other dependencies that should be fairly save. You can even install it globally. Some distributions have it packaged (pacman -S python-debugpy. Then you can use require("dap-python").setup("python")

And additionally 1 virtualenv per project with the project dependencies.

mesa123123 commented 6 months ago

Hey @mfussenegger I'm having a similar issue, though I'm using relative imports so from ..custom_logging.logger import loggy And its having problems running the dap as it returns this: image

Here's my output of :DapShowLog

[ DEBUG ] 2024-01-16T12:27:01Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1366 ]    "Spawning debug adapter"    {
  args = { "-m", "debugpy.adapter" },
  command = "/home/bowmanpete/.pyenv/versions/sn_bb_email/bin/python",
  enrich_config = <function 1>,
  options = {
    source_filetype = "python"
  },
  type = "executable"
}
[ DEBUG ] 2024-01-16T12:27:01Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    adapterID = "nvim-dap",
    clientID = "neovim",
    clientName = "neovim",
    columnsStartAt1 = true,
    linesStartAt1 = true,
    locale = "en_NZ.utf8",
    pathFormat = "path",
    supportsProgressReporting = true,
    supportsRunInTerminalRequest = true,
    supportsStartDebuggingRequest = true,
    supportsVariableType = true
  },
  command = "initialize",
  seq = 1,
  type = "request"
}
[ DEBUG ] 2024-01-16T12:27:01Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    category = "telemetry",
    data = {
      packageVersion = "1.8.0"
    },
    output = "ptvsd"
  },
  event = "output",
  seq = 1,
  type = "event"
}
[ DEBUG ] 2024-01-16T12:27:01Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    category = "telemetry",
    data = {
      packageVersion = "1.8.0"
    },
    output = "debugpy"
  },
  event = "output",
  seq = 2,
  type = "event"
}
[ DEBUG ] 2024-01-16T12:27:01Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    exceptionBreakpointFilters = { {
        default = false,
        description = "Break whenever any exception is raised.",
        filter = "raised",
        label = "Raised Exceptions"
      }, {
        default = true,
        description = "Break when the process is exiting due to unhandled exception.",
        filter = "uncaught",
        label = "Uncaught Exceptions"
      }, {
        default = false,
        description = "Break when exception escapes into library code.",
        filter = "userUnhandled",
        label = "User Uncaught Exceptions"
      } },
    supportsClipboardContext = true,
    supportsCompletionsRequest = true,
    supportsConditionalBreakpoints = true,
    supportsConfigurationDoneRequest = true,
    supportsDebuggerProperties = true,
    supportsDelayedStackTraceLoading = true,
    supportsEvaluateForHovers = true,
    supportsExceptionInfoRequest = true,
    supportsExceptionOptions = true,
    supportsFunctionBreakpoints = true,
    supportsGotoTargetsRequest = true,
    supportsHitConditionalBreakpoints = true,
    supportsLogPoints = true,
    supportsModulesRequest = true,
    supportsSetExpression = true,
    supportsSetVariable = true,
    supportsStepInTargetsRequest = true,
    supportsTerminateRequest = true,
    supportsValueFormattingOptions = true
  },
  command = "initialize",
  request_seq = 1,
  seq = 3,
  success = true,
  type = "response"
}
[ INFO ] 2024-01-16T12:27:01Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:744 ]  "Telemetry" "ptvsd"
[ INFO ] 2024-01-16T12:27:01Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:744 ]  "Telemetry" "debugpy"
[ DEBUG ] 2024-01-16T12:27:01Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    cwd = "/home/bowmanpete/dev/SN/sn_bb_email_service",
    name = "Launch file",
    program = "/home/bowmanpete/dev/SN/sn_bb_email_service/src/utils/data_utils.py",
    pythonPath = "/home/bowmanpete/.pyenv/versions/sn_bb_email/bin/python",
    request = "launch",
    type = "python"
  },
  command = "launch",
  seq = 2,
  type = "request"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  event = "initialized",
  seq = 4,
  type = "event"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    breakpoints = { {
        line = 17
      } },
    lines = { 17 },
    source = {
      name = "data_utils.py",
      path = "/home/bowmanpete/dev/SN/sn_bb_email_service/src/utils/data_utils.py"
    },
    sourceModified = false
  },
  command = "setBreakpoints",
  seq = 3,
  type = "request"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    breakpoints = { {
        id = 0,
        line = 17,
        source = {
          name = "data_utils.py",
          path = "/home/bowmanpete/dev/SN/sn_bb_email_service/src/utils/data_utils.py"
        },
        verified = true
      } }
  },
  command = "setBreakpoints",
  request_seq = 3,
  seq = 5,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    filters = { "uncaught" }
  },
  command = "setExceptionBreakpoints",
  seq = 4,
  type = "request"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  command = "setExceptionBreakpoints",
  request_seq = 4,
  seq = 6,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  command = "configurationDone",
  seq = 5,
  type = "request"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  command = "configurationDone",
  request_seq = 5,
  seq = 7,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  command = "launch",
  request_seq = 2,
  seq = 8,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    isLocalProcess = true,
    name = "/home/bowmanpete/dev/SN/sn_bb_email_service/src/utils/data_utils.py",
    pointerSize = 64,
    startMethod = "launch",
    systemProcessId = 25545
  },
  event = "process",
  seq = 9,
  type = "event"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    reason = "started",
    threadId = 1
  },
  event = "thread",
  seq = 10,
  type = "event"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    allThreadsStopped = true,
    description = "attempted relative import with no known parent package",
    preserveFocusHint = false,
    reason = "exception",
    text = "ImportError",
    threadId = 1
  },
  event = "stopped",
  seq = 11,
  type = "event"
}
[ DEBUG ] 2024-01-16T12:27:02Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  command = "threads",
  seq = 6,
  type = "request"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    threads = { {
        id = 1,
        name = "MainThread"
      } }
  },
  command = "threads",
  request_seq = 6,
  seq = 12,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    threadId = 1
  },
  command = "stackTrace",
  seq = 7,
  type = "request"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    stackFrames = { {
        column = 1,
        endColumn = 52,
        id = 2,
        line = 10,
        name = "<module>",
        source = {
          path = "/home/bowmanpete/dev/SN/sn_bb_email_service/src/utils/data_utils.py",
          sourceReference = 0
        }
      } },
    totalFrames = 1
  },
  command = "stackTrace",
  request_seq = 7,
  seq = 13,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    threadId = 1
  },
  command = "exceptionInfo",
  seq = 8,
  type = "request"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    module = {
      id = 0,
      name = "__main__",
      path = "/home/bowmanpete/dev/SN/sn_bb_email_service/src/utils/data_utils.py"
    },
    reason = "new"
  },
  event = "module",
  seq = 14,
  type = "event"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    module = {
      id = 1,
      name = "runpy",
      path = "/usr/lib64/python3.11/runpy.py"
    },
    reason = "new"
  },
  event = "module",
  seq = 15,
  type = "event"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    breakMode = "unhandled",
    description = "attempted relative import with no known parent package",
    details = {
      message = "attempted relative import with no known parent package",
      source = "/home/bowmanpete/dev/SN/sn_bb_email_service/src/utils/data_utils.py",
      stackTrace = '  File "/home/bowmanpete/dev/SN/sn_bb_email_service/src/utils/data_utils.py", line 10, in <module>\n    from ..custom_logging.logger import make_me_a_loggy\nImportError: attempted relative import with no known parent package\n',
      typeName = "ImportError"
    },
    exceptionId = "ImportError"
  },
  command = "exceptionInfo",
  request_seq = 8,
  seq = 16,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    frameId = 2
  },
  command = "scopes",
  seq = 9,
  type = "request"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    scopes = { {
        expensive = false,
        name = "Locals",
        presentationHint = "locals",
        source = vim.empty_dict(),
        variablesReference = 3
      }, {
        expensive = false,
        name = "Globals",
        source = vim.empty_dict(),
        variablesReference = 4
      } }
  },
  command = "scopes",
  request_seq = 9,
  seq = 17,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    variablesReference = 3
  },
  command = "variables",
  seq = 10,
  type = "request"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    variablesReference = 4
  },
  command = "variables",
  seq = 11,
  type = "request"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    variables = { {
        evaluateName = "special variables",
        name = "special variables",
        type = "",
        value = "",
        variablesReference = 5
      }, {
        evaluateName = "function variables",
        name = "function variables",
        type = "",
        value = "",
        variablesReference = 6
      }, {
        evaluateName = "class variables",
        name = "class variables",
        type = "",
        value = "",
        variablesReference = 7
      }, {
        evaluateName = "requests",
        name = "requests",
        type = "module",
        value = "<module 'requests' from '/home/bowmanpete/.pyenv/versions/sn_bb_email/lib64/python3.11/site-packages/requests/__init__.py'>",
        variablesReference = 8
      } }
  },
  command = "variables",
  request_seq = 10,
  seq = 18,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-01-16T12:27:03Z+0000 ] ...pete/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 14  {
  body = {
    variables = { {
        evaluateName = "special variables",
        name = "special variables",
        type = "",
        value = "",
        variablesReference = 9
      }, {
        evaluateName = "function variables",
        name = "function variables",
        type = "",
        value = "",
        variablesReference = 10
      }, {
        evaluateName = "class variables",
        name = "class variables",
        type = "",
        value = "",
        variablesReference = 11
      }, {
        evaluateName = "requests",
        name = "requests",
        type = "module",
        value = "<module 'requests' from '/home/bowmanpete/.pyenv/versions/sn_bb_email/lib64/python3.11/site-packages/requests/__init__.py'>",
        variablesReference = 8
      } }
  },
  command = "variables",
  request_seq = 11,
  seq = 19,
  success = true,
  type = "response"
}

And the dap-python config is:

local function get_python_path()
    if vim.env.VIRTUAL_ENV then
        return path.join(vim.env.VIRTUAL_ENV, "bin", "python")
    end
    return fn.exepath("python3") or fn.exepath("python") or "python"
end

local python_path = get_python_path()
dappy.setup(python_path)
dappy.test_runner = "pytest"
dap.configurations.python = {
    {
        type = "python",
        request = "launch",
        name = "Launch file",
        program = "${file}",
        cwd = fn.getcwd(),
        pythonPath = python_path,
    },
}

I'm wondering about the pythonPath variable specifically, and I'm not sure how it can relates to the PYTHON_PATH env variable, my current theory is that I somehow need debugpy to register that the project directory sn_bb_email_service is in my PATH though I'm not sure as digging through microsoft/debugpy hasn't helped too much yet

Could you please advise, any help you can offer would be brilliant

Cheers for the amazing work on the daps for nvim they've been a lifesaver btw man!