Ubuntu环境下无法安装command-not-found包的问题求助
解决Ubuntu上安装command-not-found相关包的问题
为什么pip安装command-not-found==0.3失败
command-not-found==0.3这个版本并未在PyPI上发布,或是已被移除。你可以尝试不指定版本安装(如果仍有可用版本的话):
pip install command-not-found
但实际上,command-not-found作为Ubuntu系统自带的命令补全工具,通常是通过系统包管理器分发的,pip渠道的版本维护极不活跃,甚至可能已被废弃。
解决apt安装包找不到的问题
Ubuntu上的command-not-found工具,包名随Python版本和Ubuntu版本有差异:
- 仅针对Ubuntu 18.04及更早的Python 2环境:包名为
python-commandnotfound - 针对Ubuntu 20.04+的主流Python 3环境:包名为
python3-commandnotfound
根据你的系统版本执行对应安装命令:
# 主流Ubuntu版本(Python3环境) sudo apt install python3-commandnotfound
如果依然找不到包,先确认universe仓库是否启用(该工具属于universe源):
sudo add-apt-repository universe sudo apt update
之后再重新执行安装命令即可。
GitHub Actions环境中的处理方式
在GitHub Actions的Ubuntu runner上,需要先启用universe仓库再安装,示例步骤:
- name: Install command-not-found run: | sudo add-apt-repository universe sudo apt update sudo apt install -y python3-commandnotfound
内容的提问来源于stack exchange,提问作者vince
相关产品推荐
相关产品推荐

