pip3在Ubuntu安装失败

609 阅读1分钟

在wsl配置中遇到报错:E: Package 'python3-pip' has no installation candidate

~$ python3 --version Python 3.10.12

~$ which python3 /usr/bin/python3

~$ sudo apt install python3-pip

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python3-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python3-pip' has no installation candidate

参考了许多解决方案,不起作用,可参考stackoverflow论坛。

解决方法:

  1. 更新所有包: sudo apt update 以及 sudo apt upgrade
  2. 修复破损的依赖包: sudo apt --fix-broken install
  3. 清理包缓存: sudo apt clean以及sudo apt update
  4. 手动安装pip: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py 以及 sudo python3 get-pip.py
  5. 安装成功!