記錄一個vscode python debug時出現的錯誤:
具體錯誤如下:
E+00000.030: Error while enumerating installed packages. Traceback (most recent call last): File “/root/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-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’ …
類似如下圖(網圖,我忘截圖了):
我是在一個docker container中使用的,我的python extension版本是:v2023.22.1(也試過v2024.2.1),python版本是3.8.10。
有一些推薦做法是安裝: importlib-metadata
和 debugpy
, 在我的電腦上沒有用(但是我也安裝了)。
借鑒 github上的做法:
打開報錯提示中的py
文件,我的是:"/root/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/common/log.py"
把其中的:
swallow_exception("Error while enumerating installed packages.")
替換成以下:
swallow_exception("Error while enumerating installed packages.", level="info")
就可以解決了。