Ubuntu 22.04中Python3-pip安装多次失败,遇404错误求助
Ubuntu 22.04安装python3-pip失败的解决办法
问题描述
在Ubuntu 22.04中多次尝试安装python3-pip均失败,报错核心为无法获取libexpat1-dev包,具体报错信息:
Err:1 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 libexpat1-dev amd64 2.4.7-1ubuntu0.2 404 Not Found [IP: 185.125.190.39 80] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/e/expat/libexpat1-dev_2.4.7-1ubuntu0.2_amd64.deb 404 Not Found [IP: 185.125.190.39 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
解决步骤
先更新本地软件源缓存,执行命令:
sudo apt update本地缓存的软件包版本信息可能已过期,更新后会同步服务器最新的包索引。
更新缓存后重新尝试安装,加上
--fix-missing参数修复缺失的包:sudo apt install python3-pip --fix-missing若上述方法无效,更换国内镜像源(以清华镜像为例):
- 备份原有源文件:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak - 编辑源文件:
sudo nano /etc/apt/sources.list - 将文件内容替换为清华Ubuntu 22.04(jammy)镜像源:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse - 按
Ctrl+O保存,Ctrl+X退出编辑器,再次执行更新和安装命令:sudo apt update sudo apt install python3-pip
- 备份原有源文件:
内容的提问来源于stack exchange,提问作者Victor Ubi
相关产品推荐
相关产品推荐

