1.创建安装目录
mkdir -p /usr/local/pyhton3
2. 下载tar包并解压
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
tar -xvzf Python-3.7.0.tgz
若无wget命令:yum install -y wget
3. 安装依赖项(我的虚机啥都没有所以下面前两条是依赖项,第三条是安装的gcc等)
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel yum install -y libffi-devel yum -y install gcc automake autoconf libtool make
4. 进入Python-3.7.0目录
添加配置(后面的路径是第一步创建的安装路径):./configure --prefix=/usr/local/python3/ 执行安装:make && make install
5.建立软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
6.查看版本安装成功
python3 -V
pip3 -V