无法使用yum安装python-pip


24

我正在尝试在centos7 docker容器中安装python-pip,但我想我可能缺少某些软件包或其他东西。

[root@aasdfasdfa /]# yum -y install python-pip
Loaded plugins: fastestmirror, ovl
base                                                                                                                                                                          | 3.6 kB  00:00:00     
extras                                                                                                                                                                        | 3.4 kB  00:00:00     
updates                                                                                                                                                                       | 3.4 kB  00:00:00     
updates/7/x86_64/primary_db                                                                                                                                                   | 8.4 MB  00:00:31     
Loading mirror speeds from cached hostfile
 * base: repos.lax.quadranet.com
 * extras: mirrors.unifiedlayer.com
 * updates: mirrors.usc.edu
No package python-pip available.
Error: Nothing to do

我需要先运行什么才能yum -y install python-pip正确安装。请注意,这easy_install也是坏的,所以这不是一个选择。

Answers:


39

您必须启用EPEL回购,使用:

yum --enablerepo=extras install epel-release

此命令将为您正在运行的CentOS版本安装正确的EPEL存储库。

之后,您将能够安装python-pip。


1
就我而言,在安装epel-release之后,当我要安装某些东西时,我仍然必须告诉yum使用epel仓库。类似于:yum --disablerepo =“ *” --enablerepo =“ epel”安装软件包。
rph

5

我为同一问题发疯。yum找不到python-pip的原因是它不再被称为python-pip。从EPEL版本7开始,它被重命名以标识python版本。现在,在我的centOS机器上,我可以找到以下python * -pip软件包。

[root@asdasdasdasdsa ~]# yum info python*-pip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.rz.uni-frankfurt.de
 * epel: mirrors.mit.edu
 * extras: mirror.23media.de
 * updates: ftp.plusline.de
Available Packages
Name        : python2-pip
Arch        : noarch
Version     : 8.1.2
Release     : 5.el7
Size        : 1.7 M
Repo        : epel/x86_64
Summary     : A tool for installing and managing Python 2 packages
URL         : http://www.pip-installer.org
License     : MIT
Description : Pip is a replacement for `easy_install
            : <http://peak.telecommunity.com/DevCenter/EasyInstall>`_.  It uses mostly the
            : same techniques for finding packages, so packages that were made
            : easy_installable should be pip-installable as well.

Name        : python34-pip
Arch        : noarch
Version     : 8.1.2
Release     : 5.el7
Size        : 1.7 M
Repo        : epel/x86_64
Summary     : A tool for installing and managing Python3 packages
URL         : http://www.pip-installer.org
License     : MIT
Description : Pip is a replacement for `easy_install
            : <http://peak.telecommunity.com/DevCenter/EasyInstall>`_.  It uses mostly the
            : same techniques for finding packages, so packages that were made
            : easy_installable should be pip-installable as well.

yum install python-pip由于python2-pip提供python-pip,您可以在RHEL / CentOS v7上使用相同的功能(您可以使用查看yum provides python-pip)。所以我想你还有另一个问题。
富兰克林·皮亚特

4

默认情况下,CentOS Docker映像不包括EPEL存储库,就像常规CentOS安装一样。您应该yum install epel-release首先-在那之后,yum install python-pip应该工作。


0

如果即使在安装epel存储库后仍然遇到相同的错误,请尝试:

sudo yum install -y --enablerepo="epel" python-pip


0

对于CentOS 8,您需要运行以下命令:

dnf install python2-pip # For Python 2
dnf install python3-pip # For Python 3

然后您可以使用pip3或pip2

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.