1. 程式人生 > >CentOS 7.5 安裝 Python3.7

CentOS 7.5 安裝 Python3.7

shu .sh dev ins 轉載 openssl 開發者 環境變量 profile

一、安裝開發者工具

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

五、配置環境變量

文件: /etc/profile.d/python37.sh

if [ -z ${PYTHON37_HOME} ]; then
    export PYTHON37_HOME=/usr/local/python3.7
    export PATH=${PYTHON37_HOME}/bin:${PATH}
fi

六、加載環境變量

source /etc/profile.d/python37.sh

七、測試

python3 -c "
import sys; print(sys.version)"

作者:imsilence

轉載自:https://www.jianshu.com/p/a67527356807

CentOS 7.5 安裝 Python3.7