作者:admin,发布日期:2018-05-12
阅读:8959;评论:0

写在开头

        家里的网换移动了,连博客卡的要死,所以这篇文章是在云服务器上写的。

        python3.6.5已经出来一段时间了,众所周知,centos自带的python是python2,不自带python3,以前博主都是靠编译完的安装包安装python的,不用yum主要是epel源里的python3版本太低,又找不到其他好的源,这回终于找到了,所以记录下。

        我们使用的是IUS源,IUS(Inline with Upstream Stable)是一个社区项目,它旨在为Linux企业发行版提供可选软件的最新版RPM软件包。 IUS软件替换CentOS基本源中的软件使用的是安全替换的方式:即当CentOS系统中安装了相应的软件后,再使用IUS源安装相应的软件,IUS软件不会直接更新升级系统自带的软件源,而是提示一个冲突,如果要安装IUS软件,需要先卸载CentOS系统中自带的相应的软件。

安装步骤

安装EPEL软件源

IUS依赖于EPEL,直接yum安装即可

yum -y install epel-release

安装IUS软件源

请根据您的系统选择rpm包:

  • https://rhel6.iuscommunity.org/ius-release.rpm

  • https://rhel7.iuscommunity.org/ius-release.rpm

  • https://centos6.iuscommunity.org/ius-release.rpm

  • https://centos7.iuscommunity.org/ius-release.rpm

我的系统是CentOS7,那么我们选择CentOS7的源并安装

[root@VM_0_5_centos ~]# rpm -ivh https://centos7.iuscommunity.org/ius-release.rpm
Retrieving https://centos7.iuscommunity.org/ius-release.rpm
Preparing...                          ################################# [100%]
	package ius-release-1.0-15.ius.centos7.noarch is already installed

安装完成后进入下一步

安装python3.6.5

直接安装即可

yum -y install python36u python36u-pip

安装完成后,检查是否安装成功

[root@VM_82_242_centos ~]# python3.6
Python 3.6.5 (default, Apr 10 2018, 17:08:37) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root@VM_82_242_centos ~]# pip3.6 -V
pip 9.0.1 from /usr/lib/python3.6/site-packages (python 3.6)

建立连接

用的朋友可能会感觉python3.6这个命令太长,那么我们可以做连接,更加贴近习惯

[root@VM_82_242_centos ~]# ln /usr/bin/python3.6 /usr/bin/python3
[root@VM_82_242_centos ~]# ln /usr/bin/pip3.6 /usr/bin/pip3

然后就可以使用pip3,python3命令

[root@VM_82_242_centos ~]# python3
Python 3.6.5 (default, Apr 10 2018, 17:08:37) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit();
[root@VM_82_242_centos ~]# pip3 -V
pip 9.0.1 from /usr/lib/python3.6/site-packages (python 3.6)

总结

一键安装

yum -y install epel-release # 安装epel源
rpm -ivh https://centos7.iuscommunity.org/ius-release.rpm # 安装IUS源 
yum -y install python36u python36u-pip # 安装python3.6.5
# 建立软连接
ln /usr/bin/python3.6 /usr/bin/python3
ln /usr/bin/python3.6m /usr/bin/python3m
ln /usr/bin/pip3.6 /usr/bin/pip3


评论区

发表评论

必填

选填

选填

必填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。