#进入 python 官网下载对应版本,比如:Python-3.7.12
[root@localhost ~]# wget https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz
#安装依赖包
[root@localhost ~]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make
[root@localhost ~]# tar xvf Python-3.7.12.tgz
执行cd Python-3.7.12进入到解压后的Python-3.7.12目录下,依次执行如下三个命令:
[root@localhost ~]# ./configure --prefix=/usr/local/python3
[root@localhost ~]# make
[root@localhost ~]# make install
[root@localhost ~]# unlink /usr/bin/python
[root@localhost ~]# ln -s /usr/local/python3/bin/python3 /usr/bin/python
#因为yum是python 2写的,所以需要修改yum脚本的python名称
vi /usr/bin/yum
#!/usr/bin/python2.7
#如果系统不安装图形化界面则不需要做以下操作
vi /usr/libexec/urlgrabber-ext-down
#!/usr/bin/python2.7
标签:操作系统,3.7,Python,devel,python,usr,linux,root,localhost From: https://blog.51cto.com/u_15596926/6031699