Centos7默认自带的python版本为2.7.5,但是很多软件都基于python3开发的,所以升级python3还是有必要的。
查看和备份python2.7.5
[root@test ~]# python -V
Python 2.7.5
###查看软连接指向
[root@test ~]# ls -al /usr/bin/python
lrwxrwxrwx 1 root root 7 May 19 19:39 /usr/bin/python -> python2
### 重命名软连接
mv /usr/bin/python /usr/bin/python2.7.5
升级前安装依赖软件:
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
下载和编译安装python3.7.3
cd /use/local/src
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
tar xf Python-3.7.3.tar.xz
cd Python-3.7.3
./configure
make
make install
编辑一下 yum 的配置文件,应用yum使用python 2.7.5
[root@vps219074 Python-3.7.3]# vi /usr/bin/yum
#!/usr/bin/python
修改为
#!/usr/bin/python2.7.5
[root@vps219074 Python-3.7.3]# vi /usr/libexec/urlgrabber-ext-down
#!/usr/bin/python
修改为
#!/usr/bin/python2.7.5
建立新的链接
rm -rf /usr/bin/python
rm -rf /usr/bin/py
ln -s /usr/local/bin/python3.7 /usr/bin/python
验证python是都升级成功,重新生成yum缓存
yum clean all
yum makecache
#python -V
Python 3.7.3
还没有任何评论,你来说两句吧