1)通过源码编译安装需要依赖gcc,zlib等包。可通过yum安装
yum install gcc zlib*
2)此外,pip依赖ssl环境,所以还需要先安装openssl相关的依赖
yum install openssl*
3)从官网下载python3源码包之后,然后解压,进入解压目录执行以下命令:
./configure
make
make install
编译安装完成之后,pip3也一起安装了。
注意:如果make&&make install 之后发现使用pip3时报如下错误:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
说明在make&&make install编译安装之前,环境缺少openssl依赖。安照2)安装之后,再make&&make install编译安装一次。