一、Centos7 系统自带Python版本为2.7.5
Python 2.7.5
二、安装升级Python版本至3.5.1
1、获取软件安装包
[root@localhost src]# wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
2、解压软件安装包
[root@localhost src]# tar -xzvf Python-3.5.1.tgz
3、编译安装
[root@localhost src]# cd python-3.5
[root@localhost python-3.5]# ./configure --prefix=/usr/local/python3.5
[root@localhost python-3.5]# make
[root@localhost python-3.5]# make install
4、将/usr/bin目录下的原来的Python的软连接重新更名
[root@localhost ~]# mv /usr/bin/python /usr/bin/python-2.7.5
PS:改完后执行 python 命令就会提示 bash: python: 未找到命令...
5、将新版本python的软连接增加到/usr/bin目录下
ln -s /usr/local/python3.5/bin/python3.5 /usr/bin/python
6、将版本python3.5命令加入环境变量
[root@localhost ~]# vim /etc/profile
export PATH=$PATH:/usr/local/python3.5 ///将这行加到文件最下面
[root@localhost ~]# source /etc/profile ///重新加载profile
7、查看最新版本
[root@localhost ~]# python -V
python-3.5.1