My long-successful VSCode Python setup broke inexplicably.
Please, what does the error below mean? First the recommended Python 3.12 can't find _tkinter. I try an older installed version and get this. I can't use pip either, it says "externally managed environment". I'm lost.
% cd /Users/ken/Teaching/Python2024 ; /usr/bin/env /opt/local/bin/python3.9 /Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 64660 -- /Users/ken/Teaching/Python2024/turtle1.py
E+00000.193: Error while enumerating installed packages.
Traceback (most recent call last):
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/common/log.py", line 361, in get_environment_description
report(" {0}=={1}\n", pkg.name, pkg.version)
AttributeError: 'PathDistribution' object has no attribute 'name'
Stack where logged:
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/__main__.py", line 91, in <module>
main()
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/__main__.py", line 21, in main
log.describe_environment("debugpy.launcher startup environment:")
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/common/log.py", line 369, in describe_environment
info("{0}", get_environment_description(header))
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/common/log.py", line 363, in get_environment_description
swallow_exception("Error while enumerating installed packages.")
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/common/log.py", line 215, in swallow_exception
_exception(format_string, *args, **kwargs)
E+00000.030: Error while enumerating installed packages.
Traceback (most recent call last):
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/common/log.py", line 361, in get_environment_description
report(" {0}=={1}\n", pkg.name, pkg.version)
AttributeError: 'PathDistribution' object has no attribute 'name'
Stack where logged:
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
cli.main()
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 415, in main
api.ensure_logging()
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/api.py", line 61, in ensure_logging
log.describe_environment("Initial environment:")
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/common/log.py", line 369, in describe_environment
info("{0}", get_environment_description(header))
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/common/log.py", line 363, in get_environment_description
swallow_exception("Error while enumerating installed packages.")
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/common/log.py", line 215, in swallow_exception
_exception(format_string, *args, **kwargs)
E+00000.225: Error while enumerating installed packages.
Traceback (most recent call last):
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/common/log.py", line 361, in get_environment_description
report(" {0}=={1}\n", pkg.name, pkg.version)
AttributeError: 'PathDistribution' object has no attribute 'name'
Stack where logged:
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
cli.main()
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 281, in run_file
log.describe_environment("Pre-launch environment:")
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/common/log.py", line 369, in describe_environment
info("{0}", get_environment_description(header))
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/common/log.py", line 363, in get_environment_description
swallow_exception("Error while enumerating installed packages.")
File "/Users/ken/.vscode/extensions/ms-python.debugpy-2023.3.13341006-darwin-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/common/log.py", line 215, in swallow_exception
_exception(format_string, *args, **kwargs)
fixed after installing importlib-metadata and debugpy in my venv
This solved the issue for me (from https://github.com/microsoft/debugpy/issues/1379):
Locate debugpy/common/log.py under site-packages (following the path you see in the output). Find the line in that file that says:
swallow_exception("Error while enumerating installed packages.")}
replace it with: swallow_exception("Error while enumerating installed packages.", level="info")
Is incredible this hasn't been released yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With