centos编译安装python3

1. 安装依赖包

yum install wget zlib-devel

yum groupinstall Development tools

2. 获取安装包

wget https://mirrors.huaweicloud.com/python/3.6.8/Python-3.6.8.tgz

3. 解压编译(编译时间较长请耐心等待)


tar -zxvf Python-3.6.8.tgz
cd Python-3.6.8
./configure --prefix=/usr/local/python3.6 --enable-optimizations
make
make install

4. 创建软连接 或者 添加环境变量 (推荐添加环境变量)

ln -s /usr/local/python3.6/bin/python3  /usr/bin/python3
ln -s /usr/local/python3.6/bin/pip3  /usr/bin/pip3
# 在 /etc/profile 中配置环境变量
export PATH=$PATH:/usr/local/python3.6/bin/
# 然后
source /etc/profile

你可能感兴趣的:(python)