需要安装zlib-1.2.8.tar.gz
#下载地址http://www.zlib.net/
tar xzvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install
#zlib 安装完后,libz.a 在 /usr/local/lib/,zlib.h 文件在 /usr/include
#(opensuse 中 zlib.h 默认放在 /usr/local/include/中)
tar -xzvf Python-3.6.4.tgz
cd Python-3.6.4
#./configure --prefix=/usr/local/Python-3.6.4
./configure --prefix=/usr/local/Python-3.6.4 --with-zlib=/usr/include
make clean
make
make install
mv /usr/bin/python /usr/bin/python2.6 #根据需要来
cp /usr/bin/python2.6 /usr/bin/python2.6.bak #根据需要来
#mv /usr/bin/python2.6.bak /usr/bin/python2.6
ln -sf /usr/local/Python-3.6.4/bin/python3.6 /usr/bin/python
ln -s /usr/local/Python-3.6.4/bin/python3.6 /usr/bin/python3
export PATH="$PATH:/usr/local/Python-3.6.4/bin"
#export PATH="$PATH:/usr/local/bin/python"
/usr/local/Python-3.6.4/bin
#https://www.zhihu.com/question/54906859
python -m ensurepip
#pip is bundled with Python > 3.4
#On Unix-like systems use:
#python3.6 -m pip install [Package_to_install]
#python -m pip help install
原文地址:http://blog.51cto.com/4507878/2085611