Python vscode debug: Error while enumerating installed packages.解决

记录一个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-metadatadebugpy, 在我的电脑上没有用(但是我也安装了)。

借鉴 github上的做法:
打开 报错提示中的py文件,我的是:"/root/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/common/log.py"把其中的:

bash 复制代码
swallow_exception("Error while enumerating installed packages.")

替换成以下:

bash 复制代码
swallow_exception("Error while enumerating installed packages.", level="info")

就可以解决了。

相关推荐
今天又在摸鱼几秒前
py工程+爬虫
开发语言·python
李松桃2 分钟前
Python爬虫-第一课
开发语言·python
xiaobobo33303 分钟前
vscode的if结尾提示插件“If End Marker”实现了if结尾提示功能
vscode·插件·if结尾提示·if end marker
清水白石0083 分钟前
Python 项目 CI/CD 信心模型:证据驱动部署,从“勇敢上线”到“零风险发版”实战指南
驱动开发·python·ci/cd
在放️6 分钟前
Python 爬虫 · 理论基础
开发语言·爬虫·python
李松桃12 分钟前
音频的爬虫
爬虫·python·音视频
机器学习之心13 分钟前
强化学习驱动的光伏功率时间序列预测:LSTM与GRU动态权重组合方法Python
python·gru·lstm·强化学习·动态权重组合方法
m0_7471245314 分钟前
LangChain RAG Chain Types 详解
python·ai·langchain
生信研究猿14 分钟前
leetcode 234.回文链表
python·leetcode·链表
平安的平安15 分钟前
Python + AI Agent 智能体:从原理到实战,构建自主决策的 AI 助手
开发语言·人工智能·python