安装openssl与openssl-devel包
yum -y install openssl openssl-devel


到官网下载Python3的最新版
https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz

解压Python安装包(我默认放在/root下)
cd /root
tar xzvf Python-3.5.1.tgz



进入python源代码文件夹,进入Modules文件夹,修改Setup.dist,使其支持发送https请求。
cd /root/Python-3.5.1/Modules
vim Setup.dist

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
#SSL=/usr/local/ssl
#_ssl _ssl.c \
#        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
#        -L$(SSL)/lib -lssl -lcrypto
修改为
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
_ssl _ssl.c \
        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
        -L$(SSL)/lib -lssl -lcrypto



编译安装,设置安装目录为/usr/local/python-3.5,以免与系统已安装的python2冲突。
./configure --prefix=/usr/local/python-3.5
make
make install