CentOS 7 上安装 Python 3.x

2019-01-11  本文已影响12人  默默熊

方法一:
1, Get source code
cd
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
xz -d Python-3.6.1.tar.xz
tar xvf Python-3.6.1.tar

2, Compile and install
sudo mkdir /usr/local/python3
cd Python-3.6.1
sudo ./configure --prefix=/usr/local/python3 --enable-optimizations

update zlib

yum install zlib*
vi

sudo make
sudo make install

3, Replace python 2.x with python 3.x
mv /usr/bin/python /usr/bin/python2.7.5
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python

4, Update yum
sudo vi /usr/bin/yum
update the firstline, make sure it is the right path for python2

5, Verify
python
yum

方法二:
sudo yum install epel-release
sudo yum install python36

上一篇下一篇

猜你喜欢

热点阅读