源码安装python3以及yum 配置

1.下载python
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
tar -zxvf Python-3.7.3.tgz
cd Python-3.7.3.tgz
cd src
2.安装依赖
yum -y install gcc openssl-devel readline readline-devel zlib-devel libffi-devel
3.编译安装
./configure --prefix=/usr/local/soft/python3 --with-ssl
make && make install
cd /usr/local/soft/python3/bin
./python3.7
4.配置环境变量

可选

vim /etc/profile.d/python3.sh

export PYTHON_HOME=/usr/local/soft/python3
export PATH=$PYTHON_HOME/bin
python3
5.更改默认python版本
mv /usr/bin/python /usr/bin/python2.7.5
ln -s /usr/local/soft/python/bin/python3.7 /usr/bin/python
python -V
Python 3.7.3
6.配置yum

更换默认python版本后,yum不能使用了

vim /usr/bin/yum

在第一个行修改

#!/usr/bin/python ==> #!/usr/bin/python2.7.5

还有另外一个地方需要修改

vim /usr/libexec/urlgrabber-ext-down
#!/usr/bin/python ==> #!/usr/bin/python2.7.5

yum 可以正常使用


akazwz
100 声望4 粉丝

Hello World!