1.下载
官网:https://www.python.org/ftp/python/
此处我们下载最新版Python3.7.1
命令:wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
2.解压
命令:tar xvJf Python-3.7.1.tar.xz
命令:mv Python-3.7.1 /usr/local/python-3.7.1
命令:cd /usr/local/python-3.7.1/
3.安装
a.首先安装依赖包
命令:yum -y groupinstall "Development tools"
命令:yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel libffi-devel
命令:yum -y install readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
b.配置编译参数
命令:./configure --prefix=/usr/local/bin/python-3.7.1
c.编译源码
命令:make
d.安装源码
命令:make install
e.出现下列信息,说明安装成功
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1
4.创建软连接
a.删除原有的软连接文件
命令:rm -rf /usr/bin/python
b.创建新连接
命令:ln -s /usr/local/bin/python-3.7.1/bin/python3 /usr/bin/python
命令:ln -s /usr/local/bin/python-3.7.1/bin/pip3 /usr/bin/pip3
5.修复yum
a.编辑yum文件
命令:vi /usr/bin/yum
将头文件#!/usr/bin/python改为#!/usr/bin/python2.7
评论已关闭!