VSCode Python Debugger Timeout due to Attribute Error

227 Views Asked by At

I'm running Debian 10 (buster) with a native python installation version 3.7.3.

Currently I'm running a simple test script like

def main():
    print(f'\nHello world!\n')

if __name__=='__main__':
    main()

In VSCode either Run Python File and Debug Python File work as intended and print the output in the integrated terminal.

After changing the interpreter to Python 3.9.16 however I run into issues.

Run Python File still works, but Debug Python File throws the error

Timed out while waiting for debuggee to spawn

with the traceback

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/airnd/.vscode-server/extensions/ms-python.python-2023.4.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 37, in <module>
    from debugpy.server import cli
  File "/home/airnd/.vscode-server/extensions/ms-python.python-2023.4.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/__init__.py", line 7, in <module>
    import debugpy._vendored.force_pydevd  # noqa
  File "/home/airnd/.vscode-server/extensions/ms-python.python-2023.4.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/_vendored/force_pydevd.py", line 40, in <module>
    preimport('pydevd', [
  File "/home/airnd/.vscode-server/extensions/ms-python.python-2023.4.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/_vendored/__init__.py", line 126, in preimport
    import_module(name)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/airnd/.vscode-server/extensions/ms-python.python-2023.4.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydevd_plugins/__init__.py", line 5, in <module>
    __import__('pkg_resources').declare_namespace(__name__)
AttributeError: module 'pkg_resources' has no attribute 'declare_namespace'

Versions used:

  • VSCode 1.76.0
  • vscode-python v2023.4.0
  • debugpy 1.6.6
  • Python 3.7.3 / Python 3.9.16 (installed via make altinstall)

Fixes tried:

  • (re-)install setuptools
  • use older version of setuptools
  • use older version of vscode-python

I'm running out of ideas ...

0

There are 0 best solutions below