Centos7安装python3并与python2共存

1.安装必要工具

yum -y install net-tools

yum -y install wget

2. 安装相关包

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

3.下载Python3

wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

4.解压

tar -xvJf Python-3.6.2.tar.xz

5.切换进入

cd Python-3.6.2

6.编译安装

./configure prefix=/usr/local/python3

make && make install

7.python3安装完毕,/usr/local/目录下就会有python3了 因此我们可以添加软链到执行目录下/usr/bin

ln -s /usr/local/python3/bin/python3 /usr/bin/python3

Centos7安装python3并与python2共存

相关推荐