依赖包安装
yum -y install wget make gcc
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
下载安装包
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
创建存放目录
mkdir /usr/local/python3
解压
tar -zxvf Python-3.7.0.tgz
cd Python-3.7.0
指定编译目录
./configure --prefix=/usr/local/python3
编译安装
make && make install
建立软链接
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
测试是否可用
python3 -V
python -V
更换pip下载源
vim ~/.pip/pip.conf
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com