VSCode切换Python3.9后调试超时,报pkg_resources属性错误
Python 3.9.16(make altinstall安装)在VSCode中调试报错:Timed out while waiting for debuggee to spawn
环境与问题现象
- 系统:Debian 10 (buster)
- 原生Python 3.7.3:VSCode的「Run Python File」和「Debug Python File」功能均正常运行,能在集成终端输出内容。测试脚本:
def main(): print(f'\nHello world!\n') if __name__=='__main__': main()
- 通过
make altinstall安装的Python 3.9.16:「Run Python File」功能正常,但「Debug Python File」抛出错误:
Timed out while waiting for debuggee to spawn
回溯信息如下:
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'
版本信息
- VSCode 1.76.0
- vscode-python v2023.4.0
- debugpy 1.6.6
- Python 3.7.3 / Python 3.9.16
已尝试的解决措施
- 重装setuptools
- 更换旧版本setuptools
- 降级vscode-python版本
以上措施均未解决问题,寻求有效解决方案。
内容的提问来源于stack exchange,提问作者Viktor Katzy
相关产品推荐
相关产品推荐

