安装依赖包
[root@pyhton ~]# 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 gcc
下载Python
下载地址: https://www.python.org/ftp/python
[root@pyhton ~]# cd /opt/
[root@pyhton ~]# wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
[root@pyhton ~]# mkdir /usr/local/python3
[root@pyhton ~]# tar xf Python-3.7.9.tgz
[root@pyhton ~]# cd Python-3.7.9
[root@pyhton ~]# ./configure --prefix=/usr/local/pyhton3
[root@pyhton ~]# make
[root@pyhton ~]# make install
设置环境变量
[root@pyhton ~]# vim /etc/profile
export PATH=/usr/local/python3/bin:$PATH
[root@pyhton ~]# source /etc/profile
验证
[root@pyhton ~]# python3 -V
备份就版本
[root@pyhton ~]# mv /usr/bin/python /usr/bin/python27
[root@pyhton ~]# ln -s /usr/local/python3/bin/python3 /usr/bin/python
[root@pyhton ~]# python -V
[root@pyhton ~]# Python 3.7.9
网友评论