如何在Ubuntu 20.04上安装Python3-pip

14

我在一台PC上安装了Ubuntu 20.04,然后尝试开始安装Python3的pip。然而,似乎什么都不起作用。 到目前为止,我尝试了以下方法:

sudo apt install python3-pip

这是我收到的错误信息:

Reading package lists... Done
Building dependency tree       
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

我尝试了Carlos Sanchez JR提出的解决方案:如何在Ubuntu 20.04 Linux上安装Python包安装程序PIP 按照上面链接中给出的建议后,当我执行sudo apt update时,出现了以下错误:
Ign:1 cdrom://Ubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423) focal InRelease
Hit:2 cdrom://Ubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423) focal Release
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease              
Hit:6 http://archive.ubuntu.com/ubuntu focal InRelease                        
Get:5 http://kali.download/kali kali-rolling InRelease [30.5 kB]
Hit:7 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Err:5 http://kali.download/kali kali-rolling InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ED444FF07D8D0BF6
Get:8 http://kali.cs.nctu.edu.tw/kali kali-rolling InRelease [30.5 kB]
Err:8 http://kali.cs.nctu.edu.tw/kali kali-rolling InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ED444FF07D8D0BF6
Reading package lists... Done
W: GPG error: http://kali.download/kali kali-rolling InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ED444FF07D8D0BF6
E: The repository 'http://http.kali.org/kali kali-rolling InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://kali.cs.nctu.edu.tw/kali kali-rolling InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ED444FF07D8D0BF6
E: The repository 'http://kali.cs.nctu.edu.tw/kali kali-rolling InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

现在尝试运行sudo apt install python3-pip会得到和之前一样的错误信息E: Package 'python3-pip' has no installation candidate。同样地,运行sudo apt-get install python3-pip也是如此。

目前我还没有找到其他解决方案。


请在终端中运行以下命令:sudo apt-get update sudo apt-get install python3-pip - phd
https://askubuntu.com/a/378565 - phd
似乎什么都不起作用,我只好重新安装了另一个版本的Ubuntu。 - Biochem
10个回答

39

尝试使用以下命令:

sudo apt-get install python3-pip

注意: 如果您是首次安装,需先运行上述命令之前执行此步骤。

sudo apt-get update


2
我尝试了这个,但是出现了错误。最终我只安装了另一个版本的Ubuntu。现在它运行得非常好。 - Biochem
1
这对我解决了问题。我已经运行了更新,但我想我需要再次运行它。 - Stonecraft
嘭!正是我缺少的sudo apt-get update!谢谢兄弟! - not_a_generic_user

24

尝试以下命令:

sudo apt-get install python3-setuptools
sudo python3 -m easy_install install pip
python3 -m pip --version

这是在Live CD上的唯一方法。apt update在cdrom://...上没有任何内容,而python3-pip还没有准备好。但是setuptools和easy_install可以使pip3正常工作。 - Sam
这对我有效。 - Daniel

12

这意味着你有一个全新的安装。

尝试这个:

sudo apt-get update 

那么只需使用以下命令,它可以正常工作。

sudo apt-get install python3-setuptools
sudo python3 -m easy_install install pip
python3 -m pip --version

7
您需要启用宇宙软件源,以安装此正式软件包。
$ sudo add-apt-repository universe
$ sudo apt-get install python3-pip

2
这是唯一一个对我有效的。 - ninhenzo64

2

我在AWS EC2上遇到了同样的问题。 一个简单的sudo apt update解决了这个问题。


1
如果您仔细阅读完整个问题(以及提供的链接),您会发现这是我尝试过的其中一件事情。回想起来,我认为这可能是某种硬件问题。 - Biochem
在 AWS 上的新 Ubuntu Server 20.04 实例上,sudo apt update 命令解决了我的问题。 - Nathan Griffiths

1

从apt-get update的错误信息来看,这是由于kali apt源引起的。 以下签名无法验证,因为公钥不可用:NO_PUBKEY ED444FF07D8D0BF6

您可以首先运行以下命令

wget -q -O - https://archive.kali.org/archive-key.asc | apt-key add

或者

apt-key adv --keyserver hkp://keys.gnupg.net --recv-keys ED444FF07D8D0BF6
dpkg --configure -a

然后,您可以运行以下命令来安装pip。

sudo apt-get update
sudo apt install python3-pip

0

这个可能会起作用:

python3 -m pip3 install -U pip3

或者:

python3 -m pip install -U pip

我尝试了这个, 但是出错了。最终我选择安装了不同版本的Ubuntu。现在一切都运行良好。 - Biochem

0

我在Ubuntu 19.04上遇到了几乎相同的问题。看起来这个版本的仓库在运行sudo apt update时出现了问题...IP地址和仓库未被解析。

由于我在一个虚拟机中进行,所以我安装了Ubuntu 16.04,一切都按照应该的方式正常工作,没有问题。

按照这些步骤 https://docs.python-guide.org/starting/install3/linux/ 进行操作。

然后这个就可以了:

sudo apt install python3-pip


0

这对我有用(在@G.Pavan Kumar的帮助下):

步骤1:sudo apt-get update

步骤2:sudo apt-get install python3-pip

步骤3:sudo apt-get update(尝试更新,但我猜没有进行得很好,所以在以下步骤中尝试修复缺少的更新)

步骤4:sudo apt-get update --fix-missing


0

方法一:

安装pip,可以使用curl安全地下载get-pip.py文件:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

然后在下载get-pip.py的文件夹中运行以下命令:

python get-pip.py

警告:如果您正在使用由操作系统或其他软件包管理器管理的Python安装,请小心。get-pip.py不与这些工具协调,可能会使您的系统处于不一致的状态。


方法二:

使用此方法时要小心,但对我有效:

cd ~
rm -rf .local
rm -rf .cache
sudo apt get python3-pip

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接