- 安裝開發(fā)者工具
yum -y groupinstall "Development Tools"
- 安裝Python編譯依賴包
yum -y install openssl-devel zlib-devel bzip2-devel sqlite-devel readline-devel libffi-devel systemtap-sdt-devel
- 下載安裝包
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
- 解壓&編譯
tar zvxf Python-3.7.0.tgz
cd Python-3.7.0
./configure --prefix=/usr/local/python3.7 --enable-optimizations
make && make install
- 配置環(huán)境變量
文件: /etc/profile.d/python37.sh
if [ -z ${PYTHON37_HOME} ]; then
export PYTHON37_HOME=/usr/local/python3.7
export PATH=${PYTHON37_HOME}/bin:${PATH}
fi
- 加載環(huán)境變量
source /etc/profile.d/python37.sh
- 測試
python3 -c "import sys; print(sys.version)"