Centos7安装python3 环境

由于centos7原本就安装了Python2,而且这个Python2不能被删除

首先安装python3环境依赖包

yum -y groupinstall "Development tools"

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

下载python3

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

建立python3文件夹

mkdir /usr/local/python3 

解压

tar -zxvf Python-3.6.2.tar.xz

cd Python-3.6.2

./configure --prefix=/usr/local/python3

make && make install


最后两条命令运行

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

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

测试有没有安装成功,如图可以看到环境共存,安装成功。


,如

你可能感兴趣的:(Centos7安装python3 环境)