1. 下载python3.6
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
2. 解压缩
tar -zxvf Python-3.6.4.tgz
mkdir -p /usr/local/python3
3. 安装依赖
yum install openssl openssl-devel
yum install zlib zlib-devel
4.
vim Modules/Setup
#Socket module helper for socket(2) _socket socketmodule.c timemodule.c #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
5. 配置
./configure --prefix=/usr/local/python3/ --with-ssl
6. 安装
make && make install
7. 设置环境变量
cp /root/.bashrc /root/.bashrc.bak
echo 'export PATH="$PATH:/usr/local/python/bin/"' >> /root/.bashrc
8. 创建虚拟环境
virtualenv -p /usr/local/python3/bin/python3.6 py36env //会在当前的路径下生成一个py36env的文件夹
9. 激活虚拟环境
source /home/work/py36env/bin/activate
10. 退出虚拟环境
deactivate