1.准备必要的库文件
yum install -y gcc zlib-devel openssl-devel sqlite-devel
apt-get install libssl-dev tcl tk sqlite sqlite3 libbz2-1.0 libbz2-dev libexpat1 libexpat1-dev libgdbm3 libgdbm-dev libreadline5 libreadline-dev libreadline6-dev libsqlite0 libsqlite0-dev libsqlite3-0 libsqlite3-dev openssl
2.进入源代码包
./configure prefix=/usr/local/python3
3.编译安装
make -j2 && make install
4.添加bin目录到环境变量
vim /etc/profile
export PATH="$PATH:/usr/local/python3/bin"
echo 'export PATH="$PATH:/usr/local/python3/bin"' >> /etc/profile
5.升级pip
pip3 install --upgrade pip
6.安装virtualenv
pip3 install virtualenv
cd /usr/local/python3
ln -s virtualenv virtualenv3