Skip to content

DebuggerInitializationError kills the kernel #986

@krassowski

Description

@krassowski

When debugger fails to intialise, the kernel dies because DebuggerInitializationError does not get handled on import. See jupyterlab/jupyterlab#13069 for an example on how innocent code.py file might prevent user from launching the kernel.

Example traceback:

Traceback (most recent call last):
  File "/3.9.5/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/3.9.5/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/3.9.5/envs/ipython/lib/python3.9/site-packages/ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "/3.9.5/envs/ipython/lib/python3.9/site-packages/ipykernel/kernelapp.py", line 51, in <module>
    from .ipkernel import IPythonKernel
  File "/3.9.5/envs/ipython/lib/python3.9/site-packages/ipykernel/ipkernel.py", line 19, in <module>
    from .debugger import Debugger, _is_debugpy_available
  File "/3.9.5/envs/ipython/lib/python3.9/site-packages/ipykernel/debugger.py", line 22, in <module>
    from debugpy.server import api  # noqa
  File "/3.9.5/envs/ipython/lib/python3.9/site-packages/debugpy/server/__init__.py", line 7, in <module>
    import debugpy._vendored.force_pydevd  # noqa
  File "/3.9.5/envs/ipython/lib/python3.9/site-packages/debugpy/_vendored/force_pydevd.py", line 28, in <module>
    pydevd_constants = import_module('_pydevd_bundle.pydevd_constants')
  File "/3.9.5/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/3.9.5/envs/ipython/lib/python3.9/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py", line 379, in <module>
    from _pydev_bundle._pydev_saved_modules import thread, threading
  File "/3.9.5/envs/ipython/lib/python3.9/site-packages/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_saved_modules.py", line 91, in <module>
    import code as _code;    verify_shadowed.check(_code, ['compile_command', 'InteractiveInterpreter'])
  File "/3.9.5/envs/ipython/lib/python3.9/site-packages/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_saved_modules.py", line 75, in check
    raise DebuggerInitializationError(msg)
_pydev_bundle._pydev_saved_modules.DebuggerInitializationError: It was not possible to initialize the debugger due to a module name conflict.

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