CentOS7 yum 安装python3

新查看系统是否有可用的python3安装包:

如果有的话,

[root@jenkins ~]# yum list python3
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * epel: fedora.cs.nctu.edu.tw
 * extras: mirrors.163.com
 * remi-php72: mirrors.tuna.tsinghua.edu.cn
 * remi-safe: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.163.com
Installed Packages
python3.x86_64                                                       3.6.8-10.el7                                                       @base
Available Packages
python3.i686                                                         3.6.8-10.el7                                                       base 
[root@jenkins ~]#

如果没有的话,

[root@jenkins ~]# yum list python3
已加载插件:fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Determining fastest mirrors
 * base: mirrors.163.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
错误:没有匹配的软件包可以列出
[root@jenkins ~]# 
[root@jenkins ~]# yum list python
已加载插件:fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
已安装的软件包
python.x86_64                                       2.7.5-34.el7                                         @anaconda
可安装的软件包
python.x86_64                                       2.7.5-80.el7_6                                       updates 

 

如果没有可用的python3 安装包,则先

yum install -y epel-release

然后,再查一下

[root@jenkins ~]# yum list python3
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
可安装的软件包
python3.i686                                                         3.6.8-10.el7                                                        base
python3.x86_64                                                       3.6.8-10.el7                                                        base
[root@test11 yzsmk]#

最后

yum install -y python3 python3-devel

注意:python3-devel 还是要安装一下的,否则有可能会出现各种意想不到的问题。

安装完python3后,会自带 pip3

[root@jenkins ~]# which pip3
/usr/bin/pip3
[root@jenkins ~]# pip3 -V
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

此时,系统已经有两个python版本了,一个python3 ,一个python2 (CentOS7 系统一般会自带python2)

查看python3版本

[root@jenkins ~]# python3 -V
Python 3.6.8
[root@jenkins ~]# python -V
Python 2.7.5

升级pip3

pip3 install --upgrade pip

 

个人经验:

epel 这个是很常用的东西,建议给系统装一下,比如 python3 ,zabbix 都需要用到epel ,装epel很easy,只要执行下面一条命令即可:

yum install -y epel-release

 

你可能感兴趣的:(python)