【CentOS 7】安装pip
1:利用 CentOS 默认的yum源找不到 pip
1 2 3 4 5 6 7 8 9 |
[root@msp soft]# yum install python-pip Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.aliyun.com No package python-pip available. Error: Nothing to do [root@msp soft]# |
2:通过安装EPEL扩展仓库后再安装pip
EPEL(Extra Packages for Enterprise Linux 简称), 是为企业级 linux 提供的一组高质量的额外软件包, 包括但不限于 Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Enterprise Linux (OEL).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
## 其实 EPEL 就是一个 yum 源,里面包含了基本源中不包含的软件 [root@msp soft]# yum -y install epel-release Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-9 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================================================= Installing: epel-release noarch 7-9 extras 14 k Transaction Summary ======================================================================================================================================================================= Install 1 Package Total download size: 14 k Installed size: 24 k Downloading packages: epel-release-7-9.noarch.rpm | 14 kB 00:00:10 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : epel-release-7-9.noarch 1/1 Verifying : epel-release-7-9.noarch 1/1 Installed: epel-release.noarch 0:7-9 Complete! [root@msp soft]# |
3:安装、升级pip
1 2 3 4 |
# 安装 pip [root@msp soft]# yum install python-pip # 升级 pip [root@msp soft]# pip install --upgrade pip |
4:注意
通过刚刚安装且升级的pip,用这种做法,其实是针对CentOS 7 默认的 Python 2.7
1 2 3 |
[root@msp soft]# pip -V pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7) [root@msp soft]# |
因为我们之前安装的 Python版本为3.6.2,所以这个动作几乎是步废棋。
其实我们在安装 Python 3.6.2 的时候,已经自带了pip3
1 2 3 4 5 6 7 |
[root@msp soft]# /usr/local/python3.6/bin/pip3 -V pip 9.0.1 from /usr/local/python3.6/lib/python3.6/site-packages (python 3.6) [root@msp soft]# ## 由于我们配置了环境变量,直接pip3 -V [root@msp soft]# pip3 -V pip 9.0.1 from /usr/local/python3.6/lib/python3.6/site-packages (python 3.6) [root@msp soft]# |